简体   繁体   English

忽略计算中的缺失值

[英]Ignoring missing values in calculation

For example, 例如,

> a<-c(1:5)
> b<-c(10-15)
> a-b
[1]  6  7  8  9 10

Here, how to skip NAs, if present in one (a or b) or both (a and b). 如果存在一个(a或b)或同时存在(a和b),如何跳过NA。

Preferably, how to do this without any complex conditional statement? 最好,如何在没有任何复杂的条件语句的情况下执行此操作?

> a<-c(1:5)
> b<-c(10-15)

Just use na.omit(ab) 只需使用na.omit(ab)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM