[R] ddply/tapply and set function

2021-02-17 Thread A. Mani
I want a data frame (derived from another data frame) of the form Type Set 1 {1,5, 7} 2 {3,8) .. tapply(Id,Type, set) works, but does not yield a data frame. 'set' is from package set/set6/etc ddply does not seem to work with the function. How should I proceed with t

Re: [R] ddply/tapply and set function

2021-02-17 Thread Jim Lemon
Hi A, I'm unable to work out what you are using as input. Maybe: id<-data.frame(Type=c(1,2,1,1,2),set=c(1,3,5,7,8)) but that doesn't work with your tapply(id,Type,set) command. Perhaps a bit more detail? Jim On Wed, Feb 17, 2021 at 7:48 PM A. Mani wrote: > > I want a data frame (derived f

Re: [R] readline in function call with space in prompt.

2021-02-17 Thread Jeremie Juste
Hello, Sorry for the delayed reply and thanks for your feedback. I noticed this problem both on Linux and on Windows. Thanks for leading me to the solution. I'm on R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out". A common factor between the Windows and the Linux session is Emacs ESS.

[R] forecast accuracy

2021-02-17 Thread Faheem Jan via R-help
I am new in the functional time series,  my question may be stupid as  I am new, I am  functional forecasting one year a head, Know I want to check the forecast accuracy by calculating the mean absolute percentage error, but I am unable to due this R, please help me or suggest me any link which

Re: [R] forecast accuracy

2021-02-17 Thread Spencer Graves
Hello, Faheem: 1. You might get a better response if you "PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code", as it says at the bottom of each email in this list. That would make it easier for p

Re: [R] ddply/tapply and set function

2021-02-17 Thread A. Mani
The original data frame can be like Type Id 1 1 1 5 1 7 2 3 2 8 .. tapply(Id,Type,set) will yield the sets correctly (assuming the data frame is attached) but not a data frame of the form mentioned. A similar ddply command does not work at all

[R] Undesired result

2021-02-17 Thread Val
HI All, I am reading a data file which has different date formats. I wanted to standardize to one format and used a library anytime but got undesired results as shown below. It gave me year 2093 instead of 1993 library(anytime) DFX<-read.table(text="name ddate A 19-10-02 D 11/19/2006 F

Re: [R] ddply/tapply and set function

2021-02-17 Thread Bert Gunter
df <- data.frame(X1 = c(1,1,1,2,2), X2 = c(1,5,7,3,8)) > df X1 X2 1 1 1 2 1 5 3 1 7 4 2 3 5 2 8 > v <- with(df, tapply(X2, X1, c)) ## v is a list, and I would work directly with this rather than converting to a data.frame. But if you insist: > df2 <- data.frame(v, row.names = names(v))

Re: [R] Undesired result

2021-02-17 Thread John Kane
You have 4 " addFormats" commands. Maybe add one more? On Wed, 17 Feb 2021 at 10:00, Val wrote: > HI All, > > I am reading a data file which has different date formats. I wanted to > standardize to one format and used a library anytime but got > undesired results as shown below. It gave me year

Re: [R] Undesired result

2021-02-17 Thread Duncan Murdoch
On 17/02/2021 9:50 a.m., Val wrote: HI All, I am reading a data file which has different date formats. I wanted to standardize to one format and used a library anytime but got undesired results as shown below. It gave me year 2093 instead of 1993 library(anytime) DFX<-read.table(text="name dd

Re: [R] Undesired result

2021-02-17 Thread Duncan Murdoch
Just a quick note: you can simplify my function and speed it up quite a bit if speed is an issue. I had forgotten that the POSIXlt type could act like a vector; using that you don't need those inner for loops, and with a little calculation you can also do without the outer while loops. Dunca

Re: [R] Undesired result

2021-02-17 Thread Val
Very helpful and thank you so much! On Wed, Feb 17, 2021 at 12:50 PM Duncan Murdoch wrote: > > On 17/02/2021 9:50 a.m., Val wrote: > > HI All, > > > > I am reading a data file which has different date formats. I wanted to > > standardize to one format and used a library anytime but got > > unde

[R] Concatenation?

2021-02-17 Thread Parkhurst, David
If I have a vector of site abbreviations and a vector of depths in those water bodies, is there a simple way in R to combine them to make a third vector? Examples: sitedepth desired MU 0 MU0 MU 1 MU1 MU 2 MU2 MC 0

Re: [R] Concatenation?

2021-02-17 Thread Eric Berger
desired <- paste(site,depth,sep="") On Wed, Feb 17, 2021 at 11:10 PM Parkhurst, David wrote: > If I have a vector of site abbreviations and a vector of depths in those > water bodies, is there a simple way in R to combine them to make a third > vector? > Examples: > > sitedepth des

Re: [R] [External] Concatenation?

2021-02-17 Thread Richard M. Heiberger
> paste(c("A","B","C"), c(1,2,3), sep="") [1] "A1" "B2" "C3" in your example paste(site, depth, sep="") From: R-help on behalf of Parkhurst, David Sent: Wednesday, February 17, 2021 4:09 PM To: r-help@r-project.org Subject: [External] [R] Concatenation?

Re: [R] [External] Concatenation?

2021-02-17 Thread Parkhurst, David
Thank you. From: Richard M. Heiberger Date: Wednesday, February 17, 2021 at 4:21 PM To: Parkhurst, David , r-help@r-project.org Subject: Re: [External] [R] Concatenation? > paste(c("A","B","C"), c(1,2,3), sep="") [1] "A1" "B2" "C3" in your example paste(site, depth, sep="") __

Re: [R] [External] Concatenation?

2021-02-17 Thread Bert Gunter
... or simply > paste0(c("A","B","C"), c(1,2,3)) [1] "A1" "B2" "C3" See ?paste for other useful options. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Wed, F

Re: [R] ddply/tapply and set function

2021-02-17 Thread A. Mani
Update: The whole problem was due to set() from library sets. 'sets' is not a very consistent package, and users should be warned. Set$new() and as.Set() from set6 work in a predictable, object-oriented way. Thanks and Best A Mani Prof.Dr.(Miss) A Mani ASL, AMS, ISRS, CLC, CMS, MTA Senior Membe