Jose Augusto Jr - jamaj - terra
2005-Sep-03 02:52 UTC
[R] Problems plotting time-series with multiple lines
Dear Sirs, I want to plot a time series with lines, one for each variable. I have a dataset with dates, and the values. How can i plot? I could plot one variable using index plot, bu i want to put the labels on X axis. But i had two problems: 1) The plot function, when i try to plot(x,y), incorectly sort the date (on X axis). My dataset has the date in string format "%d/%m/%Y). If i try to converto to date using as.Date(Dataset.dates,"%d/%m/%Y) it interprets the %Y incorrectly. 2) I have 187 rows. So i have to plot only some of the dates, not all. Please, help me. Thanks in advance. Best Regards, Jos?? Augusto M. de Andrade Jr. "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around darkened rooms, munching magic pills and listening to repetitive electronic music." (Kristian Wilson, Nintendo, Inc. 1989)
Gabor Grothendieck
2005-Sep-03 03:53 UTC
[R] Problems plotting time-series with multiple lines
On 9/2/05, Jose Augusto Jr - jamaj - terra <jamaj at terra.com.br> wrote:> Dear Sirs, > > I want to plot a time series with lines, one for each variable. > I have a dataset with dates, and the values. > How can i plot? > I could plot one variable using index plot, bu i want to put the labels on X > axis. But i had two problems: > 1) The plot function, when i try to plot(x,y), incorectly sort the date (on > X axis). My dataset has the date in string format "%d/%m/%Y). > If i try to converto to date using > as.Date(Dataset.dates,"%d/%m/%Y) > it interprets the %Y incorrectly.Please provide a reproducible example.> > 2) I have 187 rows. So i have to plot only some of the dates, not all.Check out plot.Date, lines.Date and axis.Date. Also plot.zoo in the zoo package may be of use.
Felipe Csaszar
2005-Sep-03 09:32 UTC
[R] Problems plotting time-series with multiple lines
He you checked this example?: z <- ts(matrix(rt(200 * 8, df = 3), 200, 8), start = c(1961,1), frequency = 12) z <- window(z[, 1:3], end = c(1969, 12)) plot(z, plot.type = "single", lty = 1:3, col = 4:2) It is from the help page of plot.ts Felipe "Jose Augusto Jr - jamaj - terra" <jamaj at terra.com.br> wrote in message news:001b01c5b032$933e8a90$6300a8c0 at 3k54gri437t... Dear Sirs, I want to plot a time series with lines, one for each variable. I have a dataset with dates, and the values. How can i plot? I could plot one variable using index plot, bu i want to put the labels on X axis. But i had two problems: 1) The plot function, when i try to plot(x,y), incorectly sort the date (on X axis). My dataset has the date in string format "%d/%m/%Y). If i try to converto to date using as.Date(Dataset.dates,"%d/%m/%Y) it interprets the %Y incorrectly. 2) I have 187 rows. So i have to plot only some of the dates, not all. Please, help me. Thanks in advance. Best Regards, Jos?? Augusto M. de Andrade Jr. "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around darkened rooms, munching magic pills and listening to repetitive electronic music." (Kristian Wilson, Nintendo, Inc. 1989) ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html