Simon Jackson shows how to run the same model against separate groups of data in R:
Now that we can separate data for each group(s), we can fit a model to each tibble in
data
usingmap()
from the purrr package (alsotidyverse
). We’re going to add the results to our existing tibble usingmutate()
from the dplyr package (again,tidyverse
). Here’s a generic version of our pipe with adjustable parts in caps:
Read the whole thing. Hat tip, R-Bloggers.