【发布时间】:2021-02-26 14:29:13
【问题描述】:
我有这段代码可以同时运行多个线性模型,每个模型的每个级别都是分开的。首先,我使用filter 和group_by 对数据进行子集化,然后使用do() 构建模型并使用tidy() 显示输出
dados <- read.table("Rafael_bovo_dados2.txt", h=TRUE)
dim(dados)#dimensões da tabela
head(dados); str(dados)
df_lm <- dados %>%
filter(Species == "Physalaemus_cuvieri") %>%
group_by(Mountain_Range) %>%
do(mod = lm(EWL_ug~as.factor(Altitude),data = .))
df_lm %>%
tidy(mod)
最后一行用于返回一个表格,其中包含所有这些模型的汇总统计信息和其他结果,例如 this vignette 中的那些。但是,这现在会返回一个错误,指出不推荐使用 tidy。
Error in var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = na.rm) :
is.atomic(x) is not TRUE
In addition: Warning messages:
1: Data frame tidiers are deprecated and will be removed in an upcoming release of broom.
2: `data_frame()` is deprecated as of tibble 1.1.0.
Please use `tibble()` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated.
3: In mean.default(X[[i]], ...) :
argument is not numeric or logical: returning NA
4: In mean.default(X[[i]], ...) :
argument is not numeric or logical: returning NA
5: In var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = na.rm) :
NAs introduced by coercion
如何更改代码以返回包含统计信息和 P 值的整个表?
【问题讨论】: