-1

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

  • 1
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Please don't share data or code as an image. – MrFlick Dec 05 '21 at 02:38

1 Answers1

1

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.

deschen
  • 10,012
  • 3
  • 27
  • 50