Questions tagged [broom]

broom is an R package for converting statistical analysis objects into "tidy" data frames

Thebroom package provides functions for converting statistical analysis objects into "tidy" tibbles in the R programming language.

The three main verbs of broom are:

  • tidy() summarizes information about model components;
  • glance() reports information about the entire model;
  • augment() adds informations about observations to a dataset.

For more information:

339 questions
31
votes
3 answers

Successor to ggplot2::fortify

In the most recent version of ggplot2, ?fortify returns: Description Rather than using this function, I now recomend using the broom package, which implements a much wider range of methods. fortify may be deprecated in the future. The broom…
Hugh
  • 15,521
  • 12
  • 57
  • 100
28
votes
0 answers

Comparison between dplyr::do / purrr::map, what advantages?

When using broom I was used to combine dplyr::group_by and dplyr::do to perform actions on grouped data thanks to @drob. For example, fitting a linear model to cars depending on their gear…
aurelien
  • 859
  • 1
  • 15
  • 22
16
votes
1 answer

Using dplyr and broom to compute kmeans on a training and test set

I am using dplyr and broom to compute kmeans for my data. My data contains a test and training set of X and Y coordinates and are grouped by a some parameter value (lambda in this case): mds.test = data.frame() for(l in seq(0.1, 0.9, by=0.2)) { …
user2117258
  • 515
  • 4
  • 18
15
votes
1 answer

Getting predicted values at response scale using broom::augment function

I'm fitting glm model in R and can get predicted values at response scale using predict.glm(object=fm1, type="response") where fm1 is the fitted model. I wonder how to get predicted values at response scale using augment function from broom package.…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
12
votes
1 answer

Error - No tidy method for objects of class lmerMod

I am using a dataset from an online practice tutorial and the code can be found at the bottom of Page 4 (https://tomhouslay.files.wordpress.com/2017/02/indivvar_mv_tutorial_asreml.pdf) In the tutorial, they get the function to work using the code…
qsxsqsxs
  • 161
  • 1
  • 8
12
votes
3 answers

installation of package had non-zero exit status

I've just updated R to version 3.6.2 "dark and stormy night" released December 12th last year. I've tried installing the following packages but have received the same error, "installation of package X had non-zero exit status". The packages include:…
j9000
  • 386
  • 1
  • 3
  • 14
11
votes
3 answers

retreiving tidy results from regression by group with broom

The answer to this question clearly explains how to retrieve tidy regression results by group when running a regression through a dplyr pipe, but the solution is no longer reproducible. How can one use dplyr and broom in combination to run a…
C. Rea
  • 121
  • 1
  • 7
11
votes
3 answers

Use broom and tidyverse to run regressions on different dependent variables

I'm looking for a Tidyverse / broom solution that can solve this puzzle: Let's say I have different DVs and a specific set of IVS and I want to perform a regression that considers every DV and this specific set of IVs. I know I can use something…
Luis
  • 1,388
  • 10
  • 30
10
votes
4 answers

rolling regression by group in the tidyverse?

There are many questions about rolling regression in R, but here I am specifically looking for something that uses dplyr, broom and (if needed) purrr. This is what makes this question different. I want to be tidyverse consistent. Is is possible to…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
10
votes
3 answers

Draw SpatialPolygons with multiple subpolygons and holes using ggplot2

I would like to draw SpatialPolygons from library sp with holes in ggplot2. Thanks to others questions on stackoverflow, I know that this is allowed while dealing with clockwise written…
Sébastien Rochette
  • 6,536
  • 2
  • 22
  • 43
9
votes
3 answers

loess regression on each group with dplyr::group_by()

Alright, I'm waving my white flag. I'm trying to compute a loess regression on my dataset. I want loess to compute a different set of points that plots as a smooth line for each group. The problem is that the loess calculation is escaping the…
Alex Nesta
  • 393
  • 2
  • 13
9
votes
4 answers

Creating models and augmenting data without losing additional columns in dplyr/broom

Consider the following data / example. Each dataset contains a number of samples with one observation and one estimate: library(tidyverse) library(broom) data = read.table(text = ' dataset sample_id observation estimate A A1 4.8 4.7 A A2 …
slhck
  • 36,575
  • 28
  • 148
  • 201
8
votes
1 answer

Using `broom:::glance` in a dplyr workflow with a single lm object fails

When I use broom:::glance in the following way: library(dplyr) library(broom) mtcars %>% do(model = lm(mpg ~ wt, .)) %>% glance(model) I get Error in complete.cases(x) : invalid 'type' (list) of argument However, when I add a group_by: mtcars %>%…
Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149
8
votes
1 answer

R2 values - dplyr and broom

I am using the dplyr and broom combination (per below) and following Fitting several regression models with dplyr to extract the regression coefficients of regressions by group. However - i am also interested in the R2 value of each individual…
user1885116
  • 1,757
  • 4
  • 26
  • 39
6
votes
2 answers

Iterating over multiple regression models and data subsets in R

I am trying to learn how to automate running 3 or more regression models over subsets of a dataset using the purrr and broom packages in R. I am doing this with the nest %>% mutate(map()) %>% unnest() flow in mind. I am able to replicate examples…
user11151932
  • 223
  • 1
  • 5
1
2 3
22 23