2

Converting the character "6/07/69" into a date using the as.Date function results in "2068-07-06" instead of "1968-07-06". How can I fix this?

Example:

as.Date(c("6/07/68", "6/07/69"), format="%d/%m/%y")
[1] "2068-07-06" "1969-07-06"
plannapus
  • 18,529
  • 4
  • 72
  • 94
phx
  • 332
  • 4
  • 13
  • Adding a century to year might not be helpful in my case. I have messy data. It is important for me to distinguish cases with and without century within the data. – phx Apr 25 '13 at 11:46
  • 1
    Did you read the answers? They give you the methodology to deal with the general problem – mnel Apr 25 '13 at 11:48

1 Answers1

3

you can use library chron

e.g.

> library(chron)
> as.Date(chron(c("6/07/67", "6/07/69"), format = c(dates = "m/d/y")))
#[1] "1967-06-07" "1969-06-07"
user1317221_G
  • 15,087
  • 3
  • 52
  • 78