我有一个.csv
文件,其中包含50列,包括文本,数字,数量和百分比。当我将数据导出到.xlsx
中时,所有金额和百分比列都将转换为文本。有帮助吗?
我的下面的代码:
datafile <- choose.files("", caption = " Select files ")
data <- read.csv(datafile, header = TRUE, sep = "," )
write.xlsx(data, file = "abc.xlsx" , sheetName = "UtilizationReportGRE", row.names = F)
答案 0 :(得分:1)
Write.xlsx将因子转换为字符串。在使用write.xlsx之前,请更改数据以使数字列变为数字等。另请参见How to convert a data frame column to numeric type?