Re: [R] write function to convert to date or delete

2014-02-27 Thread William Dunlap
Error in as.POSIXlt.character(as.character(x), ...) : character string is not in a standard unambiguous format. That error occurs when as.POSIXlt is looking for a format with which to parse the strings. If you supply a format for the date then as.POSIXlt will not give this error - it will

[R] write function to convert to date or delete

2014-02-26 Thread Bill
I have a dataframe that looks like the below. I want to convert the Captured.Time field to a date object. but some of the entries are not properly formated and I get a message saying Error in as.POSIXlt.character(as.character(x), ...) : character string is not in a standard unambiguous format.

Re: [R] write function to convert to date or delete

2014-02-26 Thread Pascal Oettli
Hello, Could you provide an example of unproperly formatted entry? Regards, Pascal On 27 February 2014 15:03, Bill william...@gmail.com wrote: I have a dataframe that looks like the below. I want to convert the Captured.Time field to a date object. but some of the entries are not properly

Re: [R] write function to convert to date or delete

2014-02-26 Thread Bill
Hi. Thanks. Actually I don't know which ones are causing problems. I cannot search through it because it is quite large (15 million records) On Thu, Feb 27, 2014 at 7:22 PM, Pascal Oettli kri...@ymail.com wrote: Hello, Could you provide an example of unproperly formatted entry? Regards,

Re: [R] write function to convert to date or delete

2014-02-26 Thread Pascal Oettli
Hello, Did you tried the strptime function? Regards, Pascal On 27 February 2014 15:24, Bill william...@gmail.com wrote: Hi. Thanks. Actually I don't know which ones are causing problems. I cannot search through it because it is quite large (15 million records) On Thu, Feb 27, 2014 at 7:22

Re: [R] write function to convert to date or delete

2014-02-26 Thread Bill
I just tried this: z - strptime(radSampTrim$Captured.Time[1:30], %d%b%Y) z[1:3] [1] NA NA NA On Thu, Feb 27, 2014 at 7:39 PM, Pascal Oettli kri...@ymail.com wrote: strptime [[alternative HTML version deleted]] __ R-help@r-project.org

Re: [R] write function to convert to date or delete

2014-02-26 Thread Pascal Oettli
Hello, I think this should be z - strptime(radSampTrim$Captured.Time[1:30], %F %T) Regards, Pascal On 27 February 2014 15:58, Bill william...@gmail.com wrote: I just tried this: z - strptime(radSampTrim$Captured.Time[1:30], %d%b%Y) z[1:3] [1] NA NA NA On Thu, Feb 27, 2014 at

Re: [R] write function to convert to date or delete

2014-02-26 Thread Bill
Yes! that worked. By the way, still puzzled about how to write the function that would delete ones where there was an error in the function I used. Any idea on that? On Thu, Feb 27, 2014 at 8:06 PM, Pascal Oettli kri...@ymail.com wrote: z - strptime(radSampTrim$Captured.Time[1:30], %F %T)

Re: [R] write function to convert to date or delete

2014-02-26 Thread Pascal Oettli
Hello, Maybe one possiblity is to search complete cases, such as complete.cases(z), and subset according to the output. It might also be interesting to check why you sometimes get NA. Regards, Pascal On 27 February 2014 16:11, Bill william...@gmail.com wrote: Yes! that worked. By the way,