[R] Importing time series

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Wed Jul 29 10:06:41 CEST 2009


On Wed, 29 Jul 2009, Bogaso wrote:

>
> I have a time series dataset, saved in a csv file. However date-formatting is
> :
>
> 7/2/1982
> 7/6/1982
> 7/7/1982
> 7/8/1982
> 7/13/1982
> 7/14/1982
>
> However if I use following zoo-code, it is not reading data:
>
> read.zoo(file="F:/data.csv", format="%m/%d/%y", header=F)

Your example is not reproducible, so it's hard to tell but I guess that 
you need %Y instead of %y. The following example works for me.
Z

data <- textConnection("7/2/1982 1
7/6/1982 2
7/7/1982 3
7/8/1982 4
7/13/1982 5
7/14/1982 6
")
z <- read.zoo(data, format = "%m/%d/%Y", header = FALSE)


> Error is
> Error in read.zoo(file ="F:/data.csv", format = "%m/%d/%y",  :
>  index contains NAs
>
> Here I have the mandate to keep date formating in abovementioned way. Can
> anyone please tell me what to do here?
>
> Regards,
>
> -- 
> View this message in context: http://www.nabble.com/Importing-time-series-tp24713580p24713580.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>
>




More information about the R-help mailing list