我是 R 新手,但我有一个微阵列数据集。我在一个位置有一个 NA 值,我尝试使用 library(impute) 中的 impute.knn(),但是在通过 impute.knn() 函数运行矩阵之后,它似乎变成了另一种结构。谁能解释发生了什么?
> m <- as.matrix(m)
# checking structure
> str(m)
num [1:22283, 1:20] 1942.1 40.1 72.1 4693.6 35.9 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:22283] "1007_s_at" "1053_at" "117_at" "121_at" ...
..$ : chr [1:20] "GSM146778-Normal" "GSM146780-Normal" "GSM146782-Normal"
# checking missing value of cell
> m[x,y]
[1] NA
# impute missing value
> m.i <- impute.knn(m, 6)
# check value of imputed value
> m.i[x,y]
Error in r.imp["206054_at", "GSM146784-Normal"] : incorrect number of dimensions
# check structure of imputed matrix
> str(m.i)
List of 3
$ data : num [1:22283, 1:20] 1942.1 40.1 72.1 4693.6 35.9 ...
..- attr(*, "dimnames")=List of 2
.. ..$ : chr [1:22283] "1007_s_at" "1053_at" "117_at" "121_at" ...
.. ..$ : chr [1:20] "GSM146778-Normal" "GSM146780-Normal" "GSM146782-Normal" "GSM146784-Normal" ...
$ rng.seed : num 3.62e+08
$ rng.state: int [1:626] 403 50 1992223309 -108730617 1600482030 698744776