我在文件/表格的两列上运行cor.test。'x'必须是数字向量:来自data.frame的数字错误
tmp <- read.table(files_to_test[i], header=TRUE, sep="\t")
## Obtain Columns To Compare ##
colA <-tmp[compareA]
colB <-tmp[compareB]
# sctr = 'spearman cor.test result'
sctr <- cor.test(colA, colB, alternative="two.sided", method="spearman")
但我得到这个混杂错误...
Error in cor.test.default(colA, colB, alternative = "two.sided", method = "spearman") :
'x' must be a numeric vector
的值的列是数字,但
is.numeric(colA) = FALSE
class (colA) = data.frame
有什么我错过了?
'str(colA)'和'str(colB)'的结果是什么。我猜这些数据是作为因素或字符数据读取的,可能是因为您读取的数据中存在错误的字符。 – Chase
@Chase:我upvoted你的评论,但后来意识到这不是问题(见下面的答案)。事后看来,我认为这有点误导,但是我无法删除我的赞... –
@Ben and @Chase:给出'str'结果的建议虽然不错。 (我给了第二个upvote)。 – Aaron