Re: [R] Feature request for as.Date() function 20)

2009-12-02 Thread Greg Snow
] On Behalf Of nabble.30.miller_2...@spamgourmet.com > Sent: Wednesday, November 25, 2009 2:40 PM > To: r-help@r-project.org > Cc: r-help > Subject: Re: [R] Feature request for as.Date() function 20) > > On Wed, Nov 25, 2009 at 2:56 PM, jim holtman - jholt...@gmail.com > <+

Re: [R] Feature request for as.Date() function

2009-11-26 Thread Gabor Grothendieck
The situation he is referring to seems to be this: > L <- "date,value\n'2009-01-01',10\n'2009-02-01',1\n'NA', 3" > read.csv(textConnection(L), colClasses = c("Date", "numeric")) Error in charToDate(x) : character string is not in a standard unambiguous format where all the fields in the date c

Re: [R] Feature request for as.Date() function

2009-11-26 Thread nabble . 30 . miller_2555
On Thu, Nov 26, 2009 at 12:08 AM, jim holtman - jholt...@gmail.com <+nabble+miller_2555+9dc9649aca.jholtman#gmail@spamgourmet.com> wrote: > An easy way is just to write your own function that will accept "NA", > convert it to NA and then call as.Date. > I have written such a function, which ha

Re: [R] Feature request for as.Date() function 20)

2009-11-25 Thread nabble . 30 . miller_2555
An easy way is just to write your own function that will accept "NA", convert it to NA and then call as.Date. R is a functional language, so write some functions. Don't try to overload existing functions with new options that may break a lot of existing code. If you have special requirements, th

Re: [R] Feature request for as.Date() function 20)

2009-11-25 Thread nabble . 30 . miller_2555
On Wed, Nov 25, 2009 at 2:56 PM, jim holtman - jholt...@gmail.com <+nabble+miller_2555+9dc9649aca.jholtman#gmail@spamgourmet.com> wrote: > Seems to work fine in my testing: > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-co

Re: [R] Feature request for as.Date() function

2009-11-25 Thread smu
hi, it fails, when the NA is surrounded by double quotes, which is the default way of quoting of the write.table command. x <- read.csv(textConnection('date,value + + 2009-01-01,10 + + 2009-02-01,1 + + "NA", 3'), colClasses=c("Date", 'integer')) Fehler in fromchar(x) : character string is not in

Re: [R] Feature request for as.Date() function

2009-11-25 Thread jim holtman
Seems to work fine in my testing: > x <- read.csv(textConnection("date,value + 2009-01-01,10 + 2009-02-01,1 + 'NA', 3"), colClasses=c("Date", 'integer')) > > str(x) 'data.frame': 3 obs. of 2 variables: $ date :Class 'Date' num [1:3] 14245 14276 NA $ value: int 10 1 3 > x <- read.csv(textCon

[R] Feature request for as.Date() function

2009-11-25 Thread nabble . 30 . miller_2555
Hello - I have a csv file with a few date columns. Some of the records have an "NA" character string instead of the date. When I attempt to use read.csv() and typecast the columns using colClasses, I receive the following error: Error in charToDate(x) : character string is not in a stand