I know can it's possible to return the p-value
of a regression lm
by doing this:
# regression model
fit <- lm(y ~ x)
# two alternative ways to return the p-value
glance(fit)$p.value
summary(fit)$coefficients[,4][2]
However, I need to pipe the result for the purposes of what I want to do. This is what I've tried without success:
lm(y ~ x) %>% glance(.)$p.value
lm(y ~ x) %>% summary(.)$coefficients[,4][2]
reproducible example
library(magrittr)
library(broom)
x <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
y <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)