我在R中有一个由0和1组成的数据帧。 当我将它写入xlsx文件并在microsoft电子表格中打开此文件时,它会在每个单元格上显示错误,编号为:"数字存储为文本"。有没有办法在R中修复它。以下是我所做的一个示例:
write.xlsx(result,"test.xlsx",sheetName="Sheet1",row.names=F)
sapply(result,mode)
GO_ids GO.0007411 GO.0006915 GO.0006914 GO.0006464 GO.0006298 GO.0018108
"numeric" "numeric" "numeric" "numeric" "numeric" "numeric" "numeric"
GO.0006355 GO.0007155 GO.0030036 GO.0030155
"numeric" "numeric" "numeric" "numeric"
由于
答案 0 :(得分:1)
您的数据可能是一个因素:
> not_a_number <- factor(c(1, 2, 3))
> mode(not_a_number)
[1] "numeric"
> typeof(not_a_number)
[1] "integer"
> class(not_a_number)
[1] "factor"
> str(not_a_number)
Factor w/ 3 levels "1","2","3": 1 2 3
write.xlsx将因子写为字符串。