[英]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.我成功地能够使用 lubridate 进行此更改。 However, it eliminates my data frame and only keeps the new dates as values.但是,它消除了我的数据框,只将新日期保留为值。
How can I keep everything contained in the data frame?如何保留数据框中的所有内容?
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.这将用新值覆盖您的日期列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.