Re: [R] Convert date to continuous variable in R

2017-07-06 Thread MacQueen, Don
Looks good, but there are some ways in which I think you’re making it more complicated than necessary. Two calls to plot(), with plot.new() in between, is definitely not needed. Recalculating LAI_simulation$Date three times should not be needed. ## create example data day0 <- as.Date('2009-10-7'

Re: [R] Convert date to continuous variable in R

2017-07-06 Thread Ahmed Attia
Thanks it worked for me. I wanted to plot days since planting on x-axis 1 and years on x-axis 3. LAI_simulation$Date <- as.Date( LAI_simulation$Date, '%Y/%m/%d') LAI_simulation$Date <- as.integer(LAI_simulation$Date - as.Date("2009-10-07")) plot(LAI~Date,data=LAI_simulation,xlab="Days since Oct, 7

Re: [R] Convert date to continuous variable in R

2017-07-05 Thread David L Carlson
How about > difftime(LAI_simulation$Date, LAI_simulation$Date[1], units="days") Time differences in days [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 - David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Origin