Skip to content

write function to convert to date or delete

9 messages · Pascal Oettli, Bill, William Dunlap

#
Hello,

Could you provide an example of unproperly formatted entry?

Regards,
Pascal
On 27 February 2014 15:03, Bill <william108 at gmail.com> wrote:

  
    
#
Hello,

Did you tried the "strptime" function?

Regards,
Pascal
On 27 February 2014 15:24, Bill <william108 at gmail.com> wrote:

  
    
#
Hello,

I think this should be

z <- strptime(radSampTrim$Captured.Time[1:300000], "%F %T")

Regards,
Pascal
On 27 February 2014 15:58, Bill <william108 at gmail.com> wrote:

  
    
#
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 <william108 at gmail.com> wrote:

  
    
#
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 just return
NA's for the entries that do not match the format.
   > as.POSIXlt(c("2013-02-28", "Feb 28, 2013"))
   Error in as.POSIXlt.character(c("2013-02-28", "Feb 28, 2013")) :
     character string is not in a standard unambiguous format
   > as.POSIXlt(c("2013-02-28", "Feb 28, 2013"), format="%Y-%m-%d")
   [1] "2013-02-28" NA
   > as.POSIXlt(c("2013-02-28", "Feb 28, 2013"), format="%B %d, %Y")
   [1] NA           "2013-02-28"

If the strings may be in one of several formats, loop through
the formats and decide which to accept. 

Bill Dunlap
TIBCO Software
wdunlap tibco.com