如何使用"NA"作为字符串 [英] how to use "NA" as string

查看:223
本文介绍了如何使用"NA"作为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个csv文件,其中一栏是字符类型.该变量很少有值是NA(字符串).但是,当我使用read.csv()在R中读取csv文件时,"NA"字符串存储为NA.我该如何解决?

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?

推荐答案

您可以在read.csv中使用na.strings参数:

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

这篇关于如何使用"NA"作为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆