You don't need the loop; it was converting back to numeric. Try this:
> thedate<-as.matrix(40548:40759,ncol=1)
>
> exdate<-function(){
+ mynewdate<-as.Date(thedate[,1],origin="1899-12-30")
+ print(mynewdate)
+ }
> exdate()
[1] "2011-01-05" "2011-01-06" "2011-01-07" "2011-01-08" "2011-01-09"
"
Hi All!
I'm trying to convert serial numbers in Excel to dates in R. For each
single "thedate" entry, I get a correct answer. But if I try using the for
loop, I get bizarre numbers in "mynewdata".
thedate<-as.matrix(40548:40759,ncol=1)
exdate<-function(){
mynewdate<-NULL
for(i in 1:nrow(th
2 matches
Mail list logo