1

4 列 679 行のデータ フレームがあり、genefilter パッケージの da 関数 rowttest を使用して ttest を実行する必要があります。最初の 2 つの列と他の 2 つの列をリストします。

A_R1   A_R2   B_R1    B_R2  
1       2       7      7
4       5       8      7.5
5       5       9      NA
6       5       10     NA
...

このコードを使用しましたが、「fac」が何を意味するのかよくわかりません。行数だと思いました。

#t.test is the dataframe used
ttest2=na.omit(ttest)
rowttests(as.matrix(ttest2),fac=679,tstatOnly = FALSE)

このエラーがあります:

Error in function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘rowttests’ for signature ‘"matrix", "numeric"’

また

Error in rowcoltt(x, factor(integer(ncol(x))), tstatOnly, 1L) : 
  Invalid argument 'x': must be a real matrix.

誰かが私を助けることができますか?

4

3 に答える 3

3

2 番目の引数は、t 検定が実行される (列の) グループを示す係数であることを意味します。

> m=matrix(runif(80), 20)
> rowttests(m, factor(c("M", "M", "F", "F")))
      statistic           dm     p.value
1    1.15567467  0.297622456 0.367224496
2    0.81334422  0.328723537 0.501449912
....
于 2013-02-27T14:49:03.957 に答える
0

見る?rowtests

rowttests(x, fac, tstatOnly = FALSE) x 数値行列 と fac テストするグループをコード化する因子

ここで行列と数値を指定すると、数値を因数に変換する必要があります。だから変える

rowttests(as.matrix(ttest2),fac=679,tstatOnly = FALSE)

rowttests(as.matrix(ttest2),fac=factor(679),tstatOnly = FALSE)
于 2013-02-27T09:45:56.700 に答える