我有一个表格,存储了不同长度的前缀...
ClusterTable[ClusterTable$FeatureIndex == "Prefix2",'FeatureIndex', 'FeatureValue')
这是表(ClusterTable)的一部分。
FeatureIndex FeatureValue
80 Prefix2 80
81 Prefix2 81
30 Prefix2 30
70 Prefix2 70
51 Prefix2 51
84 Prefix2 84
01 Prefix2 01
63 Prefix2 63
28 Prefix2 28
26 Prefix2 26
65 Prefix2 65
75 Prefix2 75
我使用以下代码将数据写入csv文件:
write.csv(ClusterTable, file = "My_Clusters.csv")
特征值01丢失了其前导零。
我首先尝试将该列转换为字符。
ClusterTable$FeatureValue <- as.character(ClusterTable$FeatureValue)
我也尝试将其附加到一个空字符串中,以在写入文件之前将其转换为字符串。
ClusterTable$FeatureValue <- paste("",ClusterTable$FeatureValue)
此外,我在这个表中有各种长度的前缀,所以我不能使用固定长度的简单格式说明符。例如,表格还具有值001(Prefix3),0001(Prefix4)等。谢谢。