We don't have your data to work with, but we can show the principle of how this can be done using the built-in mtcars
data set.
First we create a model:
model <- glm(mpg ~ ., data = mtcars)
Next, we store the result of the summary
function, which actually produces a list-like object of class summary.glm
.
model_summary <- summary(model)
The coefficient table is stored as a matrix inside this object, as a member called coefficients
:
model_summary$coefficients
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 12.30337416 18.71788443 0.6573058 0.51812440
#> cyl -0.11144048 1.04502336 -0.1066392 0.91608738
#> disp 0.01333524 0.01785750 0.7467585 0.46348865
#> hp -0.02148212 0.02176858 -0.9868407 0.33495531
#> drat 0.78711097 1.63537307 0.4813036 0.63527790
#> wt -3.71530393 1.89441430 -1.9611887 0.06325215
#> qsec 0.82104075 0.73084480 1.1234133 0.27394127
#> vs 0.31776281 2.10450861 0.1509915 0.88142347
#> am 2.52022689 2.05665055 1.2254035 0.23398971
#> gear 0.65541302 1.49325996 0.4389142 0.66520643
#> carb -0.19941925 0.82875250 -0.2406258 0.81217871
We can easily convert this to a data frame, and convert its row names to their own column:
coefs <- as.data.frame(model_summary$coefficients)
coefs$variable <- rownames(coefs)
Although a data frame is actually a list of variables (and it would be more useful to leave the result in data frame format for most applications), if you want to convert it to a list you can simply do:
as.list(coefs)
#> $Estimate
#> [1] 12.30337416 -0.11144048 0.01333524 -0.02148212 0.78711097 -3.71530393
#> [7] 0.82104075 0.31776281 2.52022689 0.65541302 -0.19941925
#>
#> $`Std. Error`
#> [1] 18.71788443 1.04502336 0.01785750 0.02176858 1.63537307 1.89441430
#> [7] 0.73084480 2.10450861 2.05665055 1.49325996 0.82875250
#>
#> $`t value`
#> [1] 0.6573058 -0.1066392 0.7467585 -0.9868407 0.4813036 -1.9611887
#> [7] 1.1234133 0.1509915 1.2254035 0.4389142 -0.2406258
#>
#> $`Pr(>|t|)`
#> [1] 0.51812440 0.91608738 0.46348865 0.33495531 0.63527790 0.06325215
#> [7] 0.27394127 0.88142347 0.23398971 0.66520643 0.81217871
#>
#> $variable
#> [1] "(Intercept)" "cyl" "disp" "hp" "drat"
#> [6] "wt" "qsec" "vs" "am" "gear"
#> [11] "carb"