我想读取一个csv文件,然后从csv文件的每一行中创建3个矩阵,然后应用使用方法chisq.test的卡方检验(矩阵),但不知何故,这种方法似乎失败了。在R中使用chisq.test(卡方测试)
它给了我下面的错误:
Error in sum(x) : invalid 'type' (list) of argument
在另一方面,如果我只需创建一个矩阵通过一些数字,然后它工作正常。 我也尝试在两种类型的矩阵上运行str。
我使用csv文件中的行创建。 str on that给出:
List of 12 $ : int 3 $ : int 7 $ : int 3 $ : int 1 $ : int 7 $ : int 3 $ : int 1 $ : int 1 $ : int 1 $ : int 0 $ : int 2 $ : int 0 - attr(*, "dim")= int [1:2] 4 3
使用某些数字创建的矩阵。对海峡给出:
num [1:2, 1:3] 1 2 3 4 5 6
有人能告诉我这到底是怎么回事呢?谢谢。
您正在向chisq.test传递一个列表,而不是矩阵。让我们看看你的代码,甚至更好。一个小的可重现的例子。 – 2011-03-09 08:00:17
建议阅读:http://cran.r-project.org/doc/manuals/R-lang.html#Objects – nico 2011-03-09 08:15:09