我正在尝试将数据集中的整数转换为单个字符和日期,没有运气:我尝试了以下
# input data
elog <- read.csv("data.csv",sep = ",", as.is = T)
elog[1:3,]
elog$cust <- toString(elog$cust)
elog$date <- toString(elog$date)
elog$date <- as.Date(elog$date, "%Y%m%d");
它给了我以下内容:
转换前:
转换后:
我想重新创建的最终结果:
答案 0 :(得分:0)
您需要as.character
# input data
elog <- read.csv("data.csv", sep = ",", as.is = T)
elog[1:3,]
elog$cust <- as.character(elog$cust)
elog$date <- as.character(elog$date)
elog$date <- as.Date(elog$date, "%Y%m%d")