簡體   English   中英

從 R 中的 emmeans 包中提取函數輸出的一部分

[英]Extract part of a function output from package emmeans in R

我想知道如何從gg的輸出中提取標題為degree = linear:的部分?

library(emmeans)

dat <- read.csv('https://raw.githubusercontent.com/rnorouzian/e/master/dat2.csv')

fit <- lm(math ~ time*ses + I(time^2)*ses, data = dat)

( gg <- emtrends(fit, ~ses, var= "time", max.degree= 2,at =list(ses=0,time=0)) )

degree = linear:
 ses time.trend      SE   df lower.CL upper.CL  
   0     0.3416 0.06084 1594   0.2222  0.46091  ##### Extract this part from `gg`

degree = quadratic:
 ses time.trend      SE   df lower.CL upper.CL
   0    -0.0221 0.00835 1594  -0.0385 -0.00572

您可以在gg上應用summary並將其轉換為數據幀。

data.frame(summary(gg))
#  ses    degree  time.trend          SE   df    lower.CL     upper.CL
#1   0    linear  0.34156633 0.060844787 1594  0.22222212  0.460910546
#2   0 quadratic -0.02209907 0.008349954 1594 -0.03847712 -0.005721024

我們可以使用tidy from broom

library(broom)
tidy(gg)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM