how to use “NA” as string

陌路散爱 提交于 2019-12-23 12:50:52

问题


I have one csv file in which one column is character-type. Few values of that variable are NA (string). But when I am reading csv file in R using read.csv(), the "NA" strings are stored as NA. How can I fix it?


回答1:


You can use the na.strings argument in read.csv:

read.csv("myfile.csv", na.strings = "NNN")



回答2:


Not sure what you are asking really, but a pseudo use could be something such as:

if (null == column)
{
     column = "NA";
}


来源:https://stackoverflow.com/questions/33126182/how-to-use-na-as-string

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!