Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 我如何修正这个t-test错误-它说;数据基本上是不变的;?_R - Fatal编程技术网

R 我如何修正这个t-test错误-它说;数据基本上是不变的;?

R 我如何修正这个t-test错误-它说;数据基本上是不变的;?,r,R,这是我的代码,下面是我得到的错误: t.test(replication$Expecatation_Factor, replication$Amused_After_centered) #replication$Expecatation_Factor is a factor as verified by str() and class() #replication$Amused_After_centered is an integer as verified by srt() and clas

这是我的代码,下面是我得到的错误:

t.test(replication$Expecatation_Factor, replication$Amused_After_centered)

#replication$Expecatation_Factor is a factor as verified by str() and class()
#replication$Amused_After_centered is an integer as verified by srt() and class()
报告的错误

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 var(x) :   Calling var(x) on a factor x is deprecated and will
become an error.   Use something like 'all(duplicated(x)[-1L])' to
test for a constant vector.
if中的
错误(标准偏差<10*.Machine$double.eps*max(abs(mx)),
abs(my)))stop(“数据基本不变”):缺少值
如果需要TRUE/FALSE,另外:警告消息:1:In
mean.default(x):参数不是数字或逻辑参数:返回NA 2:
在var(x)中:对因子x调用var(x)是不推荐的,并且将
成为一个错误。使用类似“all(复制的(x)[-1L])”的语句
测试一个常数向量。

如果看不到实际的数据集,很难准确地说出发生了什么,但您使用的向量之一似乎不是真正的数字。请参阅下面的内容,了解尝试对字符串变量使用t.test时发生的情况;很接近你的警告

> t.test(factor(c('a', 'b', 'c')), c(1, 2, 3)) # you can't run a t-test on c('a', 'b', 'c')
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 var(x) :
  Calling var(x) on a factor x is deprecated and will become an error.
  Use something like 'all(duplicated(x)[-1L])' to test for a constant vector.
>t.test(因子(c('a','b','c'))、c(1,2,3))#您不能对c('a','b','c')运行t-test
if(stderr<10*.Machine$double.eps*max(abs(mx)、abs(my))停止时出错(“数据基本保持不变”):
缺少需要TRUE/FALSE的值
此外:警告信息:
1:平均值。默认值(x):参数不是数字或逻辑参数:返回NA
2:在var(x)中:
对因子x调用var(x)已被弃用,并将成为一个错误。
使用类似“all(复制的(x)[-1L])”的方法测试常量向量。

您打算如何处理该因素?这样调用
t.test()
时,它需要两个数值。您的意思是使用组的公式语法吗?像
t.test(在以实验为中心,数据=复制之后感到有趣)