获得“NA"当我运行标准偏差时 [英] Getting "NA" when I run a standard deviation

查看:18
本文介绍了获得“NA"当我运行标准偏差时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速提问.我将我的 csv 文件读入变量 data.它有一个列标签 var,其中包含数值.

Quick question. I read my csv file into the variable data. It has a column label var, which has numerical values.

当我运行命令时

sd(data$var)

我明白了

[1] NA 

而不是我的标准偏差.

instead of my standard deviation.

你能帮我弄清楚我做错了什么吗?

Could you please help me figure out what I am doing wrong?

推荐答案

尝试 sd(data$var, na.rm=TRUE) 然后将忽略列 var 中的任何 NA.还将支付检查您的数据以确保 NA 应该是 NA 并且没有读取错误,命令如 head(data)tail(data)str(data) 应该对此有所帮助.

Try sd(data$var, na.rm=TRUE) and then any NAs in the column var will be ignored. Will also pay to check out your data to make sure the NA's should be NA's and there haven't been read in errors, commands like head(data), tail(data), and str(data) should help with that.

这篇关于获得“NA"当我运行标准偏差时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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