我使用 R,当我尝试运行以下代码时:
f = scan(file="c:\\myfile.txt", sep=' ', what=list('numeric'))
MY_MATRIX.M = matrix(f, ncol = 4, byrow = TRUE)
Var.names = c('column1','column2', 'column3', 'column4')
colnames(MY_MATRIX.M) = Var.names
TEST = data.frame(MY_MATRIX.M)
t1 = TEST[which(TEST[,4] == 0, arr.ind = TRUE),]
t2 = TEST[which(TEST[,4] == 1, arr.ind = TRUE),]
我有以下错误:
Error in which(TEST[,4] == 0, arr.ind = TRUE :
(list) object cannot be coerced to type 'double'
我的文件有 4 列,由数组等数字组成。谁能帮我解决这个问题?