[R] datetime data and plotting
Gabor Grothendieck
ggrothendieck at myway.com
Fri Oct 17 19:16:00 CEST 2003
The problem is related to time zones. The easiest way to
handle this is to avoid using POSIXt and use chron instead
so you don't have to worry about them.
require(chron)
day <- 6:16
dts <- dates(paste("10", day, "03", sep="/"))
plot(dts,day)
abline(v=dts)
---
From: Jacob Etches <jetches at iwh.on.ca>
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
_______________________________________________
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com
More information about the R-help
mailing list