Search code examples
rlubridate

How to convert a Date column with lubridate and keep it within the dataframe?


Currently, I am trying to change my date column that is stored as a character type into a date type. I am successfully able to use lubridate to make this change. However, it eliminates my data frame and only keeps the new dates as values.

How can I keep everything contained in the data frame?

Code


Solution

  • You are overwriting your entire data frame with the value for the newly created date column.

    Instead do

    dc.crime.complete$Date <- ymd(dc.crime.complete$Date)
    

    This will overwrite your date column with the new values.