Try the zoo package: Lines <- "time[sec] , Factor1 , Factor2 00:00:00 01.01.2007 , 0.0000 , 0.176083 01:00:00 01.01.2007 , 0.0000 , 0.176417 11:00:00 10.06.2007 , 0.0000 , 0.148250 12:00:00 10.06.2007 , NA , 0.147000 13:00:00 10.06.2007 , NA , 0.144417"
library(zoo) library(chron) z <- read.zoo(textConnection(Lines), sep = ",", header = TRUE, format = "%H:%M:%S %m.%d.%Y", tz = "", strip.white = TRUE) plot(z) and read the three vignetttes (pdf documents) that come with it. On Wed, Jul 15, 2009 at 10:07 AM, Keith<kigio...@gmail.com> wrote: > Hello everyone, > > I am just a tyro in R and would like your kindly help for some > problems which I've been struggling for a while but still in vain. > > I have a time-series file (with some missing value ) which looks like > > time[sec] , Factor1 , Factor2 > 00:00:00 01.01.2007 , 0.0000 , 0.176083 > 01:00:00 01.01.2007 , 0.0000 , 0.176417 > [ ... ] > 11:00:00 10.06.2007 , 0.0000 , 0.148250 > 12:00:00 10.06.2007 , NA , 0.147000 > 13:00:00 10.06.2007 , NA , 0.144417 > [ ... ] > > and I would like to do some basic time-series analyses using R. The > first idea is to plot these time-series events and the main problem > was the handling of the date/time format in the 1st column. I was > using the script below to deal with: > > data <- > read.table("file",header=TRUE,sep=",",colClasses=c("character","numeric","numeric")) > data$time.sec. <- as.POSIXct(data$time.sec.,format="%H:%M:%S %d.%m.%Y") > dataTs <- as.ts(data) > plot.ts(dataTs) > > Then, the plot showed up with 3 subplots in one plot. The 1st is the > linear line with the x-axis being just the sequence of orders and > y-axis being wrong numbers which is completely wrong. The 2nd and the > 3rd are correct but the x-axis is still wrong. Does anyone know how to > plot correct Factor1 and Factor2 with respect to the 1st column time > format? Or, probably should I use some other packages? Besides, how > can I plot these two time-series data (Factor1 and Factor2) in two > separate plots? > > Best regards, > Keith > > ______________________________________________ > R-help@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. > ______________________________________________ R-help@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.