Here are a couple of ways that you can do it: x <- expand.grid(YEAR=c(2003,2004), MONTH=1:12, DAY=1, STATE=LETTERS[1:4]) x$SALES <- runif(nrow(x), 10, 100) # add date for plotting x$date <- ISOdate(x$YEAR, x$MONTH, x$DAY) # sort into date order for plotting x <- x[order(x$date),] # you can use lattice require(lattice) xyplot(x$SALES ~ x$date | x$STATE, type='l') # or you can use base plot par(mfrow=c(2,2)) invisible(lapply(split(x, x$STATE), function(.state){ plot(.state$date, .state$SALES, type='l', main=.state$STATE[1]) }))
On 10/15/07, gsmkb86 <[EMAIL PROTECTED]> wrote: > > hi: > Yesterday I post a message about hoy to plot a time series, but someone told > me to post more information about the file so here it is: > the file was read using read.table and the name is list. When I use > str(list) it tells the following variables: > YEAR int: 2003,2003,2003....2004 > MONTH int:1,1,1,1,.... > DAY:int 1,1,1,... > STATE: factor with 51 levels. > SALES: int (sales per day) > The reason why the month day and year are repeated is because there is 1 > observation on day 1 month 1 and year 1 for each state. > What i want to do is plot a time series for every state (each separated but > in the same page) being on Y axis the sales and on the X axis the time. Any > help is greatly appreciated. > Thanks in advance. > -- > View this message in context: > http://www.nabble.com/Need-help-ploting-time-series%282%29-tf4628022.html#a13214340 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? ______________________________________________ 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.