简体   繁体   English

在R中使用t.test()时出错-观察次数不足

[英]Error using t.test() in R - not enough 'x' observations

I try to conduct a t.test, but it gives me such a mistake. 我尝试进行t.test,但这给了我一个错误。
Error using t.test() in R 在R中使用t.test()时出错

not enough 'x' observations 没有足够的“ x”观察

The data has only numerical values, no NA. 数据只有数值,没有NA。 The ratio of groups is 10 to 35. How can this be circumvented? 小组的比例是10:35。如何避免这种情况? Thanks in advance for the help! 先谢谢您的帮助!

t.test(data$Vrajdeb[data$a=="1"],data$Vrajdeb[data$a=="2"])

reference to data https://1drv.ms/x/s!ApJwAUaohJFdr1ID-QebKTmE_o3K 引用数据https://1drv.ms/x/s!ApJwAUaohJFdr1ID-QebKTmE_o3K

Here is one way to do it. 这是一种方法。 Note that when I loaded your data in, the column labeled a turns up as X. : 请注意,当我加载数据时,标记为a的列会变成X.

library(dplyr)
library(broom)
> data
# A tibble: 45 x 25
      X. Cinizm Agres Vrajdeb Zavisim Motiv Stimul  Igra Rasslab Podderjka_1
   <int>  <int> <int>   <int>   <int> <int>  <int> <int>   <int>       <int>
 1     1     33    22      17       1     7      6     7      13          15
 2     1     54    38      24       3     8     13     4      13           8
 3     1     44    35      21       6     8     11    10      14           6
...

> data %>% do(tidy(t.test(Vrajdeb~X., data=.)))
   estimate estimate1 estimate2  statistic   p.value parameter  conf.low 
conf.high  method alternative
1 -1.728571      17.3  19.02857 -0.8999865 0.3819658  15.42225 -5.812628  
2.355486 Welch Two Sample t-test   two.sided

You have enough observations but you are not able to subset your data based on column 'a'. 您具有足够的观察力,但无法基于“ a”列对数据进行子集化。 This is due to your data getting imported with first column name as Unicode: <U+430> for character 'a', use an index 1 for your column 'a' or rename it as 这是由于导入的数据的第一列名称为Unicode:字符“ a”的<U+430> ,对列“ a”使用索引1或将其重命名为

colnames(data)[1] <- 'a'

Then run the t test. 然后运行t检验。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM