Anupam Tyagi
2006-Sep-09 09:42 UTC
[R] reading and formating irregular time series for VaR
Hi, I am trying to read the following type of data from a .csv file to form an irregular time series object. I want to use it with the VaR package. How do I read it in correctly to an irregular time series object? Anupam. date,Open,High,Low,Close,Volume,OpenInterest,Contract 1972-08-16,54.25,54.25,54.25,54.25,1,1,KC1973H 1972-08-17,54.25,54.25,54.25,54.25,0,1,KC1973H 1972-08-18,54.25,54.25,54.25,54.25,0,1,KC1973H 1972-08-21,54.25,54.25,54.25,54.25,0,1,KC1973H 1972-08-22,54.25,54.25,54.25,54.25,0,1,KC1973H 1972-08-23,54.25,54.25,54.25,54.25,0,1,KC1973H
Gabor Grothendieck
2006-Sep-09 13:27 UTC
[R] reading and formating irregular time series for VaR
If you are using the zoo package and if we assume: - your file contains a single time series and - the last column is junk then try this: library(zoo) DF <- read.csv("myfile.dat") z <- zoo(as.matrix(DF[2:7]), as.Date(DF[[1]])) Read the documents at the end of http://cran.r-project.org/src/contrib/Descriptions/zoo.html for more info. On 9/9/06, Anupam Tyagi <AnupTyagi at yahoo.com> wrote:> Hi, I am trying to read the following type of data from a .csv file to form an > irregular time series object. I want to use it with the VaR package. How do I > read it in correctly to an irregular time series object? Anupam. > > date,Open,High,Low,Close,Volume,OpenInterest,Contract > 1972-08-16,54.25,54.25,54.25,54.25,1,1,KC1973H > 1972-08-17,54.25,54.25,54.25,54.25,0,1,KC1973H > 1972-08-18,54.25,54.25,54.25,54.25,0,1,KC1973H > 1972-08-21,54.25,54.25,54.25,54.25,0,1,KC1973H > 1972-08-22,54.25,54.25,54.25,54.25,0,1,KC1973H > 1972-08-23,54.25,54.25,54.25,54.25,0,1,KC1973H > > ______________________________________________ > 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 > and provide commented, minimal, self-contained, reproducible code. >