Write a dataframe to csv file with value of NA as blank

后端 未结 2 992
终归单人心
终归单人心 2020-12-16 10:35

There is a dataframe named cnbd, for example:

cnbd = data.frame(1,2,3,NA,NA,5)

Thus the expression:



        
相关标签:
2条回答
  • 2020-12-16 11:04

    You can try the write.csv command:

    write.csv(cnbd, file="cnbd.csv", na="")
    
    0 讨论(0)
  • 2020-12-16 11:09

    Try this:

    write.table(df, "cnbd.csv",
                na = "",
                row.names = FALSE,
                col.names = FALSE,
                append = TRUE,
                sep = ",")
    
    0 讨论(0)
提交回复
热议问题