Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(tidyverse)
- library(broom)
- data(mtcars)
- df <- mtcars
- nest.df <- df %>% nest(-carb)
- results <- nest.df %>%
- mutate(fit = map(data, ~ lm(mpg ~ wt, data=.x)),
- tidied = map(fit, tidy),
- glanced = map(fit, glance),
- augmented = map(fit, augment))
- glanced.df <- results %>%
- unnest(glanced, .drop=T)
- tidied.df <- results %>%
- unnest(tidied, .drop=T)
- augmented.df <- results %>%
- unnest(augmented, .drop=T)
- myList <- list(glanced.df, tidied.df, augmented.df)
- names(myList) <- c("glance", "tidy", "augment")
- openxlsx::write.xlsx(myList, file = "myResults.xlsx")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement