[R] Identifying time series

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Mon Oct 4 15:42:15 CEST 2004


On Mon, 4 Oct 2004 09:00:46 -0400  John DeAngelis wrote:

> 
> 
> 
> Hello,
> 
> I am currently attempting to introduce R at my company and am trying
> to import time series data from a text file into R to graph. The
> format of the text file is in date, data (e.g.,  20040929 3.361).

You can read in such a file, e.g., via
R> x <- read.table(file = "mydata.txt", colClasses = c("character",
     "numeric"))

> My problem is that I do
> not know how to get R to recognize the first column as a business date
> series.

You can do that via strptime(), e.g.,

R> strptime(x[,1], "%Y%m%d")

(and possibly convert then to POSIXct or Date).

Then you can create an irregular time series, e.g. via package its or
via package zoo:

R> y <- zoo(x[,2], strptime(x[,1], "%Y%m%d"))
R> plot(y)

hth,
Z

> Or at the very least, I am unable to find a function that will
> grap the second column (y-axis) against the date series (x-axis). If
> you could tell me how to graph this type of data, I would greatly
> appreciate it. Thank you.
> 
> 
> Regards,
> 
> John DeAngelis
> 
> ______________________________________________
> 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
>




More information about the R-help mailing list