Running multiple simple linear regressions from a nested dataframe/tibble
问题 I am trying to run multiple simple linear regressions based on data from a nested data frame and store the regression fit coefficients in a dataframe using tidy(). My code block is as follows library(tidyverse) library(broom) library(reshape2) library(dplyr) Factors <- as.factor(c("A","B","C","D")) set.seed(5) DF <- data.frame(Factors, X = rnorm(4), Y = rnorm(4), Z= rnorm(4)) MDF <- melt(DF, id.vars=c("Factors","X")) DFF <- MDF %>% nest(-Factors) If it is a single dataframe with many columns,