0

I have a character string that is a date (month, day, year).

char <- "12/1/2014"

When I try to turn this character string into a date, and I specify month,day, year

date <- as.Date(char, origin = "%m/%d/%Y") 

it formats it like I put in year, day, month:

> date
[1] "0012-01-20"

What am I missing?

Jacob Curtis
  • 788
  • 1
  • 8
  • 22

1 Answers1

7

You need to specify the format using the format argument, not the origin argument.

(date <- as.Date("12/1/2014", format = "%m/%d/%Y"))
[1] "2014-12-01"
Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418