An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130107/da5868f9/attachment-0001.pl>
plot x-axis DateTime NOT evenly spaced
4 messages · Uwe Ligges, arun, ishi soichi
On 07.01.2013 09:55, ishi soichi wrote:
R-64 latest Hi. I am trying to plot a set of csv data, which looks like
head(interval)
date inteval 1 2012-07-01 00:57:54 +0900 156 2 2012-07-01 01:07:41 +0900 587 3 2012-07-01 01:09:31 +0900 110 4 2012-07-01 01:18:42 +0900 551 5 2012-07-01 01:39:01 +0900 1219 6 2012-07-01 01:40:40 +0900 99 as you can see, more than one event happens each day, and they are not evenly spaced. Obviously hours, minutes and seconds are important for the plot. I tried interval$date <- as.Date(interval$date, "%Y-%m-%d %H:%M:%S +0900") but this chops the time off. Could anyone show me how to plot data with x values as Date(or Time) objects?
See ?strptime Best, Uwe Ligges
soichi [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Hi,
Try this:
dat1<-read.table(text="1 2012-07-01 00:57:54 +0900??? 156
2 2012-07-01 01:07:41 +0900??? 587
3 2012-07-01 01:09:31 +0900??? 110
4 2012-07-01 01:18:42 +0900??? 551
5 2012-07-01 01:39:01 +0900??? 1219
6 2012-07-01 01:40:40 +0900????? 99",sep="",header=FALSE,stringsAsFactors=FALSE)
dat2<-data.frame(date=paste(dat1[,2],dat1[,3],paste0("+",dat1[,4]),sep=" "),Interval=dat1[,5])
dat2$date<-as.POSIXct(dat2$date,"%Y-%m-%d %H:%M:%S")
library(xts)
?dat3<-xts(dat2[,-1],order.by=dat2[,1])
plot(dat3)
A.K.
----- Original Message -----
From: ishi soichi <soichi777 at gmail.com>
To: r-help <r-help at r-project.org>
Cc:
Sent: Monday, January 7, 2013 3:55 AM
Subject: [R] plot x-axis DateTime NOT evenly spaced
R-64 latest
Hi. I am trying to plot a set of csv data, which looks like
head(interval)
? ? ? ? ? ? ? ? ? ? ? date inteval 1 2012-07-01 00:57:54 +0900? ? 156 2 2012-07-01 01:07:41 +0900? ? 587 3 2012-07-01 01:09:31 +0900? ? 110 4 2012-07-01 01:18:42 +0900? ? 551 5 2012-07-01 01:39:01 +0900? ? 1219 6 2012-07-01 01:40:40 +0900? ? ? 99 as you can see, more than one event happens each day, and they are not evenly spaced.? Obviously hours, minutes and seconds are important for the plot. I tried interval$date <- as.Date(interval$date, "%Y-%m-%d %H:%M:%S +0900") but this chops the time off. Could anyone show me how to plot data with x values as Date(or Time) objects? soichi ??? [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
1 day later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130109/30f73723/attachment-0001.pl>