convertCharToDate: Convert Character to Dates

Description Usage Arguments Value Author(s) See Also Examples

Description

Attempts to convert input vector to Date, if that fails tries to convert to double. If conversion induces NA the function returns NULL indicating a failure.

Usage

1

Arguments

x

character vector to convert to dates

Value

a vector of dates, or of doubles or NULL.

Author(s)

Johan Lindstrom

See Also

Other utility functions: defaultList

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
##a vector of dates is returned as is
convertCharToDate( seq(as.Date("2012-01-01"),as.Date("2012-01-31"),by=5) )

##if given as chracter vectors Date is returned
convertCharToDate( c("2012-01-01","2012-01-05","2012-01-10","2012-01-12") )

##double is returned as is
convertCharToDate( rnorm(5) )

##other things result in NULL
convertCharToDate( c("a","b","c") )
convertCharToDate( c("2012-01-01", "2012-01-05", "a", "2012-01-12") )
convertCharToDate( c(1,2,3,"d") )

SpatioTemporal documentation built on May 2, 2019, 8:49 a.m.