Reputation: 1
example(s) are from the pretty fantastic book "David Manipulation with R" by Phil Specter, but an error comes up.
#write a gzipped csv file created from a data frame
gfile = gzfile("mydata.gz")
write.table("mydata, sep = ",", file = gfile")
#Goal is to test a conversion from char to Date objects with function textConnection()
sample = textConnection("2002-2-29 1 0
2002-4-29 1 5
2004-10-4 2 0")
read.table(sample, colClasses = c("Date", NA, NA))
Error in charToDate(x) :
character string is not in a standard unambiguous format
#next mydata = scan(unz("data.zip", "mydata.txt"))
Upvotes: 0
Views: 125
Reputation: 132706
Feb. 29th did not exist in 2002:
as.Date("2002-02-28")
#[1] "2002-02-28"
as.Date("2002-02-29")
#Error in charToDate(x) :
# character string is not in a standard unambiguous format
as.Date("2004-02-29")
#[1] "2004-02-29"
Upvotes: 2