R 如何在统计测试中查看变量的单个值

R 如何在统计测试中查看变量的单个值,r,statistics,statistical-test,R,Statistics,Statistical Test,我有这个解决方案,它允许我在fisher测试中单独查看类型列的值。(也可以将fisher替换为chisq.测试) 但我试图将其应用于方差分析测试,结果出现了错误 这是我的原版 # fisher test status on types individually fish = lapply(unique(df$type),function(i){ ctest = fisher.test(table(df$type == i, df$status)) data.frame(type =

我有这个解决方案,它允许我在fisher测试中单独查看类型列的值。(也可以将fisher替换为chisq.测试)

但我试图将其应用于方差分析测试,结果出现了错误

这是我的原版


# fisher test status on types individually 
fish = lapply(unique(df$type),function(i){
  ctest = fisher.test(table(df$type == i, df$status))
  data.frame(type = i, pvalue = ctest$p.value)
})

我得到了这个输出,这是我对方差分析测试的期望输出

type        pvalue

warning     7.94658438e-23
noncontact  5.84265922e-01
issue       4.18245681e-04
success     1.67653259e-09
这是我尝试进行方差分析测试的一次尝试,但出现了这个错误

anov = lapply(unique(df$numtype),function(i){
  atest = aov(table(df$numtype == i ~ df$status))
  data.frame(numtype = i, pvalue = atest$p.value)
})


Error: unique() applies to only vectors

我使用的是一个数据帧,我不认为这会是一个问题

我使用的列如下所示(当然,数字列仅用于方差分析)

影响 类型 核型 地位 1. 非接触 1. 积极的 2. 警告 2. 拒绝 3. 问题 3. 积极的 4. 成功 4. 积极的 5. 成功 1. NA 6. 成功 5. 积极的 你需要这个吗

lapply(split(df, df$numtype),function(x){
  atest = aov(numtype~status, x)
  data.frame(numtype = x$numtype[1], pvalue = atest$p.value)
}) -> result

result

非常感谢,但我得到了一个错误:/“'error in data.frame(numtype=x$numtype[1],pvalue=atest$p.value]:参数意味着不同的行数:1,0”@I_love_白板你能以可复制的格式提供数据吗?这样我就可以根据数据测试我的代码了。编辑你的帖子,包括
dput(df)
的输出。