Re: [R] RFE: vectorized behavior for as.POSIXct tz argument
On Dec 2, 2011, at 2:28 PM, Jack Tanner wrote: x - 1472562988 + 1:10; tz - rep(EST,10) # Case 1: Works as documented ct - as.POSIXct(x, tz=tz[1], origin=1960-01-01) # Case 2: Fails ct - as.POSIXct(x, tz=tz, origin=1960-01-01) sapply(tz, function(ttt) as.POSIXct(x=x, tz=ttt, origin=1960-01-01),simplify=FALSE) If case 2 worked, it'd be a little easier to process paired (time, time zone) vectors from different time zones. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RFE: vectorized behavior for as.POSIXct tz argument
David Winsemius dwinsemius at comcast.net writes: sapply(tz, function(ttt) as.POSIXct(x=x, tz=ttt, origin=1960-01-01),simplify=FALSE) Sure, there's no end of workarounds. It would just be consistent to treat both the x and the tz arguments as vectors. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RFE: vectorized behavior for as.POSIXct tz argument
On Dec 2, 2011, at 4:06 PM, Jack Tanner wrote: David Winsemius dwinsemius at comcast.net writes: sapply(tz, function(ttt) as.POSIXct(x=x, tz=ttt, origin=1960-01-01),simplify=FALSE) Sure, there's no end of workarounds. It would just be consistent to treat both the x and the tz arguments as vectors. I've wondered abut that too. The function where I would like to see a dual vectorized application is 'rep'. In cases where the x argument is the same length as the 'times' or 'each' arguments I would like to see it produce a vector that is sum(each) or tume(times) long. The problem is most likely in the ambiguity of how to apply the arguments: unlist(sapply(1:5, function(tt) rep(1:5, each=tt))) [1] 1 2 3 4 5 1 1 2 2 3 3 4 4 5 5 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 1 1 1 1 2 2 2 2 3 [40] 3 3 3 4 4 4 4 5 5 5 5 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 5 5 5 5 5 mapply(rep, x=1:5, each=1:5) [[1]] [1] 1 [[2]] [1] 2 2 [[3]] [1] 3 3 3 [[4]] [1] 4 4 4 4 [[5]] [1] 5 5 5 5 5 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.