简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM