我的数据集称为“火车”。我试图提取每个元素都相同的列。但是R会引发一些错误。
silly_var<-list()
for (i in 1:ncol(train)) {
for (j in 1:nrow(train)){
if (train[1,i]!="NA"){
if (train[j,i]=="NA") break
if (train[j,i]==train[1,i]) {
if (j == nrow(train)) list.append(silly_var,colnames(train)[i])
}else break
}else
{
if (train[j,i]=="NA") {
if (j==nrow(train)) list.append(silly_var,colnames(train)[i])
}else break
}
}
}
这是我收到的错误消息。
Error in if (train[j, i] == "NA") break :
missing value where TRUE/FALSE needed