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) 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.
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. > >
The format for the year should be %Y, not %y; however, without a reproducible example (see last line to every message on R help) we can't be sure that that is the whole story. On Wed, Jul 29, 2009 at 3:00 AM, Bogaso<bogaso.christofer at gmail.com> 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) > > 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. >