I have read some posts about extracting coefficient values from lm for example here
but I would like to have only the value of intercept and not the text. What should I do?
here you can see part of my simple code:
...
f<-lm(res[,1]~res[,2])
f
...
I have read some posts about extracting coefficient values from lm for example here
but I would like to have only the value of intercept and not the text. What should I do?
here you can see part of my simple code:
...
f<-lm(res[,1]~res[,2])
f
...
If you want to use the data from the lm function, like the coefficients, p values, etc I suggest using the broom package.
Accessing the intercept can than be done using the function tidy
. this will return a data.frame.
Simple example:
library(broom)
f <- lm(speed ~ ., data = cars)
df1 <- tidy(f)
df1
term estimate std.error statistic p.value
1 (Intercept) 8.2839056 0.87438449 9.473985 1.440974e-12
2 dist 0.1655676 0.01749448 9.463990 1.489836e-12