-2

I have a column called date, chr class, format mm/dd/yyyy.

I have tried converting it to date with lubridate as follows:

df$date<- df %>% as.Date(date) 
df$date<- df %>% as_date(date) 

both resulted in the Error in as.Date.default(., date): do not know how to convert '.' to class “Date”

df$date<- df %>% mdy(date)

resulted in Error in as.character(x): cannot coerce type 'closure' to vector of type 'character'

Peter
  • 11,500
  • 5
  • 21
  • 31

1 Answers1

0
df$date <- as.Date(df$date, "%m/%d/%Y")

should do it.

U Bhalraam
  • 96
  • 7