零作为R中的遗漏案例 [英] Zeros as missing cases in R

查看:77
本文介绍了零作为R中的遗漏案例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的csv包含数百万个如下所示的案例:

I have a csv with millions of cases that look like this:

Case_1,11,17481,172,4436,8,4436
Case_2,11,1221,680,55200,1776,55200
Case_3,16,6647,6449,579967,1,579967
Case_4,22,0,0,0,0,0

在这种情况下,Case_4缺少数据,因为其中包含一堆零(文件中有数百个).我是R的新手,我想知道是否有一种有效的方法可以从文件中删除这些丢失的数据?谢谢.

In this case, Case_4 is missing data, since it has a bunch of zeros in it (there are hundreds of these in the file). I'm very new to R, and I was wondering if there is an efficient way of deleting these kinds of missing data from the file? Thanks.

推荐答案

在读取文件时使用na.strings自变量.

Use the na.strings argument when reading in your file.

df <- read.csv("filename.csv", na.strings="0")

这篇关于零作为R中的遗漏案例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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