需要将列转换为日期
names<-c("tom", "dick", "harry", "mary", "susie")
date_1<-c(15127, 15034, 15034, 15141, 15013)
date_2<-c(15155, 15062, 15064, 03/05/2019, 15041)
date_3<-c(15185, 15091, 15092, 01/20/2019, 15069)
df<-data.frame(names, date_1, date_2, date_3)
mutate(df, date_3 = as.Date(date_3, format= "%d/%m/%Y")
names<-c("tom", "dick", "harry", "mary", "susie")
date_1<-c(15127, 15034, 15034, 15141, 15013)
date_2<-c(15155, 15062, 15064, 03/05/2019, 15041)
date_3<-c(15185, 15091, 15092, 01/20/2019, 15069)
df<-data.frame(names, date_1, date_2, date_3)
mutate(df, date_3 = as.Date(date_3, format= "%d/%m/%Y")
错误:出现意外符号: “ mutate(df,date_3 = as.Date(date_3,format =”%d。%m。%Y“) df“
答案 0 :(得分:0)
请尝试使用下面的日期代码。首先安装动物园图书馆
install.packages("zoo")
library(zoo)
date_1 <- as.Date(date_1)
date_2 <- as.Date(date_2)
date_3 <- as.Date(date_3)
df <- data.frame(names,date_1,date_2,date_3)
之后,您可以转换任何格式%Y-%m-%d