Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 测试 NA 并根据结果选择值
假设你有一个向量——你对向量进行计算——许多元素返回“NA”——你如何识别这些“NA”并将它们更改为一些可用的整数
假设您的数据位于dat(可能是向量、矩阵或数据框):
dat
dat[is.na(dat)]<-0
用替换所有NA条目。dat0
NA
0