[R] Is this foreach behaviour correct?
Duncan Murdoch
murdoch.duncan at gmail.com
Sun Nov 6 23:20:07 CET 2016
On 06/11/2016 5:02 PM, Jim Lemon wrote:
> hi James,
> I think you have to have a starting date ("origin") for as.Date to
> convert numbers to dates.
That's true with the function in the base package, but the zoo package
also has an as.Date() function, which defaults the origin to
"1970-01-01". If James is using zoo his code would be okay. If he's
not, he would have got an error, so I think he must have been.
Duncan Murdoch
>
> Jim
>
> On Sun, Nov 6, 2016 at 12:10 PM, James Hirschorn
> <james.hirschorn at hotmail.com> wrote:
>> This seemed odd so I wanted to check:
>>
>> > x <- foreach(i=10000:10100, .combine='c') %do% { as.Date(i) }
>>
>> yields a numeric vector for x:
>>
>> > class(x)
>> [1] "numeric"
>>
>> Should it not be a vector of Date?
>>
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>
More information about the R-help
mailing list