R write dataframe column to csv having leading zeroes

后端 未结 7 1059
故里飘歌
故里飘歌 2020-12-21 04:21

I have a table that stores prefixes of different lengths.. snippet of table(ClusterTable)

ClusterTable[ClusterTable$FeatureIndex == \"Prefix2\",\'Feat

7条回答
  •  囚心锁ツ
    2020-12-21 04:43

    If you just need it for the visual, just need to add one line before you write the csv file, as such:

    ClusterTable <- read.table(text="   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",
                               colClasses=c("character","character"))
    
    ClusterTable$FeatureValue <- paste0(ClusterTable$FeatureValue,"\t")
    
    write.csv(ClusterTable,file="My_Clusters.csv")
    

    It adds a character to the end of the value, but it's hidden in Excel.

提交回复
热议问题