Re: [R] Loop trouble with Excel Serial Numbers!

2011-08-18 Thread jim holtman
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" "

[R] Loop trouble with Excel Serial Numbers!

2011-08-18 Thread Anna Dunietz
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