[R] Time Series

Duncan Mackay dulcalma at bigpond.com
Tue Jun 3 17:06:50 CEST 2014


Not sure where things are up to in the thread but this may illuminate things
Using the test data.frame
from an old thread I was just looking at
https://stat.ethz.ch/pipermail/r-help/2007-May/133033.html

ylabGrob <-
function(...) { # ...is lab1, lab2, etc
labs <- lapply(list(...), textGrob, rot = 90)
nlabs <- length(labs)
lab.widths <-
lapply(labs,
function(lab) unit(1, "grobwidth", data = list(lab)))
lab.layout <-
grid.layout(ncol = 1,
nrow = nlabs,
heights = unit(1, "null"),
widths = do.call(max, lab.widths), respect = TRUE)
lab.gf <- frameGrob(layout = lab.layout)
for (i in seq_len(nlabs)) {
lab.gf <- placeGrob(lab.gf, labs[[i]], row = i, col = 1)
}
lab.gf
}

xyplot(Wdose+Deldose ~ Date, test,
       outer = T,
       strip.left = T,
       strip = F,
       layout = c(1,2),
       ylab = ylabGrob("Del units","Win units"),
       par.settings = list(strip.background = list(col = "transparent")),
       scales   = list(x = list(alternating = FALSE,
                                relation    = "same",
                                rot         = 0),
                       y = list(alternating = FALSE,
                                 relation    = "same",
                                 rot         = 0)
                  ))

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of John Kane
Sent: Tuesday, 3 June 2014 23:27
To: wayne schlemitz; r-help at R-project.org
Subject: Re: [R] Time Series

I know essentially nothing about plotting time series so so I just let it pass hoping someone with knowledge of time series would help

What were you expecting to get? Just plotting the time series without labels etc, since I am getting some weird error messages about pch having a “unexpected ',' in " pch="16" and I am too lazy to bother debugging it I get a four panel plot (see attached). This does not seem make any sense to me since I don't see why Date is plotted, but as I say I know nothing about time series.

However the data did come through okay. Presumably test$Date is a date. It reads in as a factor for me which is one reason for using dput() which maintains the structure of the data.

Below is what I think your data looks like in dput() format.

Sorry not to be of more help.

test <- structure(list(Date = structure(c(15657, 15664, 15678, 15700, 15713, 15720, 15734, 15741, 15755, 15769, 15783, 15790, 15811, 15832, 15839, 15853, 15867, 15880, 15895, 15902, 15916, 15930, 15944, 15951, 15958, 15965, 15972, 15979, 15986, 16000, 16014, 16021, 16028, 16035, 16042, 16049, 16056, 16065, 16077, 16084, 16091, 16105, 16112, 16126, 16141, 16147, 16154, 16161, 16175, 16189, 16203), class = "Date"), Inr = c(2.2, 2.5, 2.4, 2.3, 2.1, 1.9, 1.9, 3.3, 2.6, 2.7, 3.1, 2.4, 2, 2.5, 2.3, 2.4, 2.3, 2.3, 2.1, 2.4, 3.6, 3, 1.3, 2.6, 1.9, 3.4, 2.4, 2.2, 2.9, 2.8, 2.1, 2.2, 2.2, 3, 2.7, 2.3, 2.7, 2.9, 2.7, 2.6, 2.6, 3.3, 2.6, 2.8, 2.9, 3.5, 2.8, 2.7, 2.5, 2.8, 2.3), Wdose = c(30, 32.5, 32.5, 35, 35, 35, 25, 40, 37.5, 37.5, 37.5, 32.5, 37.5, 35, 35, 35, 35, 35, 35, 42.5, 40, 35, 25, 40, 32.5, 35, 32.5, 35, 37.5, 35, 35, 37.5, 37.5, 40, 37.5, 37.5, 40, 40, 40, 40, 37.5, 37.5, 40, 37.5, 40, 40, 32.5, 35, 35, 35, 35), Deldose = c(NA, 2.5, 0, 2.5, 0, 0, -10, 15, -2.7, 0, 0, -5, 5, -2.5, 0, 0, 0, 0, 0, 7.5, -2.5, -5, -10, 15, -7.5, 2.5, -2.5, 2.5, 2.5, -2.5, 0, 2.5, 0, 2.5, -2.5, 0, 2.5, 0, 0, 0, -2.5, 0, 2.5, -2.5, 2.5, 0, -7.5, 2.5, 0, 0, 0)), .Names = c("Date", "Inr", "Wdose", "Deldose"), row.names = c(NA, -51L), class = "data.frame")


John Kane
Kingston ON Canada

-----Original Message-----
From: schmtzway at yahoo.com
Sent: Mon, 2 Jun 2014 08:06:33 -0700 (PDT)
To: jrkrideau at inbox.com, r-help at r-project.org
Subject: Re: [R] Time Series

John:

The data that I sent you did you receive it? If so what thoughts or suggestions do you have for plotting the time series?

I am not sure what is going wrong and getting multi plot of same.

Thank you

Wayne Schlemitz

schmtzway at yahoo.com

  On Saturday, May 24, 2014 11:34 AM, John Kane <jrkrideau at inbox.com> wrote:

No raw data.  Sent is as text (csv) or use dput() to include it in the email.

John Kane
Kingston ON Canada

> -----Original Message-----
> From: schmtzway at yahoo.com
> Sent: Fri, 23 May 2014 08:02:31 -0700 (PDT)
> To: r-help at r-project.org
> Subject: [R] Time Series
> 
> Dear Sir:
> I am trying to plot a time series from the following code:
> 
> test <- read.table("/home/wayne/inr2a.txt", header = TRUE, quote="", sep
> = ";")
> x2 <- ts(data=test, frequency = 80, start = c(2012,11), end = c(2014,5))
> plot.ts(x2, xlab="Date", ylab="Inr", main="X2 - Time Series",
> ylim=c(1.0,4.0),pch=16, col="black")
> 
> What I get is multi plots that print 3x across the plot.
> 
> Using R 2.15.2-1 on Ubuntu Natty
> Attached is the raw data.
> 
> Thank you for any suggestions.
> Wayne
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help [https://stat.ethz.ch/mailman/listinfo/r-help]
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html [http://www.r-project.org/posting-guide.html]
> and provide commented, minimal, self-contained, reproducible code.

____________________________________________________________
Protect your computer files with professional cloud backup.

Learn more at http://backup.pcrx.com/mail [http://backup.pcrx.com/mail]

____________________________________________________________
Protect your computer files with professional cloud backup.

Learn more at http://backup.pcrx.com/mail



More information about the R-help mailing list