RI には、欠損値のあるデータ フレームがあるため、read.table()
関数はNA
空白セルの代わりに s を使用します。
私はこれを書きました:
a <- sample(1000:50000000, size=120, replace=TRUE)
values <- matrix(a, nrow=6, ncol=20)
mtx <- cbind.data.frame(values, c(rep(NA),6))
mtx <- apply(mtx, 2, function(x){
if (x==NA) sample(100:500, replace=TRUE, size=nrow(mtx)) else (x)})
しかし、私はこのエラーがあります:
Error in if (x == NA) sample(100:500, replace = TRUE, size = nrow(mtx)) else (x) :
missing value where TRUE/FALSE needed
In addition: Warning message:
In if (x == NA) sample(100:500, replace = TRUE, size = nrow(mtx)) else (x) :
the condition has length > 1 and only the first element will be used
何か案は?
ベスト リカルド