[R] datetime data and plotting
Jacob Etches
jetches at iwh.on.ca
Fri Oct 17 15:21:38 CEST 2003
If I take the following simple data:
YEAR MONTH DAY WEIGHT.KG
2003 10 6 1.2
2003 10 12 1.2
2003 10 16 1.3
and format the date data and plot it:
dates <- strptime(paste(DAY,MONTH,YEAR),"%d%m%Y")
plot(c(min(dates),max(dates)),c(0,max(WEIGHT.KG)),
xlab="Date",ylab="Weight (kg)",type="n")
lines(dates,WEIGHT.KG)
points(dates,WEIGHT.KG)
I find that the data points are all plotted at (x-1,y),
where x is in days. Have I requested this behaviour
accidentally? I'm using R-1.8 on OS X.
Printing the dates object looks correct, and simple
manipulations such as max(dates)-min(dates) behave
normally.
Jacob Etches
Doctoral candidate
Dept of Public Health Sciences
University of Toronto
More information about the R-help
mailing list