我正在尝试为从另一个数据帧创建的数据帧编写t检验,但遇到了一些麻烦。我收到此错误:
Error in if (stderr < 10 * .Machine$double.eps * max(abs(mx),
abs(my))) stop("data are essentially constant") :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In mean.default(x) : argument is not numeric or logical:
returning NA
2: In mean.default(y) : argument is not numeric or logical:
returning NA
这是我为新数据框编写的代码:
t_test_domain_1 <- data.frame(matrix(NA, nrow = 14, ncol = 4))
t_test_domain_1_col_names <- c("arm", "baseline", "6mo", "12mo")
colnames(t_test_domain_1) <- t_test_domain_1_col_names
t_test_domain_1[1:7, 2] <- newest.table_summary[2:8, 4]
t_test_domain_1[8:14, 2] <- newest.table_summary[2:8, 5]
t_test_domain_1[1:7,1] <- 1
t_test_domain_1[8:14,1] <- 0
t_test_domain_1[12,2] <- 0
这是t_test_domain_1的样子:
t_test_domain_1
arm baseline 6mo 12mo [1,] "1" "3.316" NA NA [2,] "1" "3.158" NA NA [3,] "1" "2.885" NA NA [4,] "1" "3" NA NA [5,] "1" "4" NA NA [6,] "1" "3.259" NA NA [7,] "1" "2.408" NA NA [8,] "0" "3.341" NA NA [9,] "0" "3.295" NA NA [10,] "0" "2.852" NA NA [11,] "0" "3.25" NA NA [12,] "0" "0" NA NA [13,] "0" "3.075" NA NA [14,] "0" "2.418" NA NA
然后,我正尝试对基准值进行t检验,所以我写:
t.test(t_test_domain_1$baseline ~ t_test_domain_1$arm)
但是我得到上面的错误。
帮助?