I have a master data frame that contains ~200 unique 'IDs' and each of these IDs have about ~200 each 'orders'. I have split the master data frame into 200 individual data frames using
list2env(split(df, df$id), envir = .GlobalEnv)
Now since I have 200 individual data frames per each unique ID, I want to create a GLM where I can get the coefficients and R^2 value for each of these IDs printed in another master data frame.
So instead of doing (where '1' through '200' are all the IDs) :
test1 <- glm(1$response_var ~ variableA + variableB + variableC, family=gaussian(), data=1)
and manually printing the coefficients while repeating this for the 200 ID's, is there a function or certain loop I could use to get all the coefficients and R^2 value printed in a single data frame?
So for this example the end result would be 200 rows for each ID, and 6 columns for the ID, Intercept, Coefficient1, Coefficient2, Coefficient3, and R^2