我想使用package:genefilter中的rowttests
函数。 rowtests
函数参数是:
>rowttests(x, fac)
x: Numeric matrix. The matrix must not contain ‘NA’ values. For
‘rowttests’ and ‘colttests’, ‘x’ can also be an
‘ExpressionSet’.
fac: Factor which codes the grouping to be tested.
所以,我的输入是下面的数据帧,我执行以下步骤但是出错...
> dataframe
V1 V2 V3 V4
1 1 5 6 7
2 2 6 7 8
3 3 7 8 9
4 4 8 9 10
5 5 9 10 11
6 6 10 11 12
7 7 11 12 13
>mat <-as.matrix(dataframe)
> mat
V1 V2 V3 V4
[1,] 1 5 6 7
[2,] 2 6 7 8
[3,] 3 7 8 9
[4,] 4 8 9 10
[5,] 5 9 10 11
[6,] 6 10 11 12
[7,] 7 11 12 13
>fac <- factor(c(1,1,2,2))
错误是:
rowttests(mat, fac)
Error in rowcoltt(x, fac, tstatOnly, 1L) :
Invalid argument 'x': must be a real matrix.
> mode(mat)
[1] "numeric"
> class(mat)
[1] "matrix"
我也尝试过:
>mat1 <-matrix((stack(dataframe))[[1]],nrow=7, ncol=4)
>mat1
[,1] [,2] [,3] [,4]
[1,] 1 5 6 7
[2,] 2 6 7 8
[3,] 3 7 8 9
[4,] 4 8 9 10
[5,] 5 9 10 11
[6,] 6 10 11 12
[7,] 7 11 12 13
再次出现同样的错误
rowttests(mat1, fac)
Error in rowcoltt(x, fac, tstatOnly, 1L)
Invalid argument 'x': must be a real matrix.
有人能告诉我如何将数据帧转换为矩阵,以便我可以在rowttests函数中使用它吗?