-1

enter image description here

I have trouble converting double data into a date. I want to convert a date by using as_date. However, when I apply this function, I am getting strange output. I think the problem lays the horizontal line under the numbers (see the image). Does someone know how I can delete this line or escape?

1 Answers1

0

One option is to use lubridate:

library(lubridate)

df$date <- ymd(df$date)

# [1] "1995-10-11" "1995-01-03"

Or use a combination of strptime and as.Date:

df$date <- as.Date(strptime(df$date, format = "%Y%m%d"))

Data

df <- structure(list(date = c(19951011, 19950103)), row.names = c(NA, 
-2L), class = "data.frame")
AndrewGB
  • 16,126
  • 5
  • 18
  • 49