如何解决如何在 table1 包中显示具有不相等组大小的方差分析的 p 值?
我正在使用 table1 包为我的数据制作汇总表。我想添加 p 值并使用小插图中定义的函数。这个函数对数值变量使用了 t 检验,我有两个以上的组,所以我想使用方差分析。我能够让 ANOVA 独立于 p 值函数工作,但是当我将 p 值函数作为 table1 函数的一部分运行时,我收到关于组大小不等的错误。我尝试改用 Kruskal Wallis 测试,效果很好。 ANOVA 是否有任何解决方法?这是我正在使用的代码:
public string isVisible="hidden";
protected override void OnAfterRender(bool firstRender)
{
base.OnAfterRender(firstRender);
if (firstRender)
{
isVisible = "visible";
}
}
我得到的错误是:
pvalue <- function(x,...) {
# Construct vectors of data y,and groups (strata) g
y <- unlist(x)
g <- factor(rep(1:length(x),times=sapply(x,length)))
if (is.numeric(y)) {
# For numeric variables,perform an ANOVA
p <- summary(aov(y ~ g,x))[[1]][["Pr(>F)"]][1]
} else {
# For categorical variables,perform a chi-squared test of independence
p <- chisq.test(table(y,g))$p.value
}
# Format the p-value,using an HTML entity for the less-than sign.
# The initial empty string places the output on the line below the variable label.
c("",sub("<","<",format.pval(p,digits=3,eps=0.001)))
}
Error in (function (...,row.names = NULL,check.rows = FALSE,check.names = TRUE,:
arguments imply differing number of rows: 28,21,27
提前致谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。