I have a problem with creating a table with 13 different simple linear regression. it says that I should do like this "For each of the 13 predictors in the dataset, fit a simple linear regression model to predict the response (i.e. 13 simple linear regressions). Summarize your results in a table. In which of the models is there a statistically significant association between the predictor and the response? Create some plots to back up your conclusions."
How can I create one table with all of these 13 different predictors?
It seems that you recently asked a question that originated from a class or workshop, and I wanted to make sure you were seeking help here in a way that maximizes the chances of getting good help (without violating our homework policies).
Assign your regression output to an object, say model <- lm(y ~ age + sex + marital).
Then summary(model) gives you a summary of the regression.
Then str(model) will give you variable names of various pieces of the regression output.
Then create a data frame with pieces of the output you select that ought to be summarized.
you can conveniently iterate by using purrr's map family of functions.
use fcas80 advice to make a parameterised function that can do the task for any one model.
Than iterate your function over the data for as many applications of it as might be needed ( i.e. 13)