Description Usage Arguments Examples
This function converts a set of character strings to date format using the specified lubridate method
1 |
data |
Data frame or character string or vector to be manipulated |
fields |
Character vector of fields; not necessary if passing a vector |
method |
Which lubridate method to use for parsing; defaults to |
debug |
If |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ToDate(c("3-21-1911", "8-8-2008"), method="mdy")
my.dates <- data.frame(x1 = c("1911-03-21", "2008-08-08"),
x2 = c("2009-01-01", "3001-01-01"),
x3 = c("1805-12-31", "1555-06-12"),
stringsAsFactors = FALSE)
# All three columns are chr
str(my.dates)
my.dates2 <- ToDate(my.dates, fields=c("x1", "x3"))
# The first and third column are now Date, but the second is still chr
str(my.dates2)
my.dates3 <- ToDate(my.dates, fields=1:3)
# All three columns are now Date
str(my.dates3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.