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
4
votes
1 answer

Correlation matrix with dplyr, tidyverse and broom - P-value matrix

all. I want to obtain the p-value from a correlation matrix using dplyr and/or broom packages and testing multiple variables at the same time. I'm aware of other methods, but dplyr seems easier and more intuitive for me. In addition, dplyr will need…
Luis
  • 1,388
  • 10
  • 30
4
votes
1 answer

Error when using broom (augment) and dplyr with loess fit

I am trying to use augment on a loess fit, but I receive the following error: Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 32, 11 In the error message, 11 happens to equal the number of observations…
Steve
  • 135
  • 1
  • 6
4
votes
1 answer

Error in as.vector(x, mode) : cannot coerce type 'closure' to vector of type 'any'

I'm doing some practice on broom package in R. I ran the following kclusts <- data.frame(k=1:9) %>% group_by(k) %>% do(fit=kmeans(data.frame, .$k)) I have received the following error Error in as.vector(x, mode) : cannot coerce type 'closure' to…
Juanma
  • 195
  • 2
  • 4
  • 12
4
votes
1 answer

using lm in list column to predict new values using purrr

I am trying to add a column of predictions to a dataframe that has a list column that contains an lm model. I adopted some of the code from this post. I have made a toy example…
jkgrain
  • 769
  • 5
  • 20
4
votes
2 answers

How to perform operation between grouped values from two data frames

I have two data frames: src_tbl <- structure(list(Sample_name = c("S1", "S2", "S1", "S2", "S1", "S2"), crt = c(0.079, 0.082, 0.079, 0.082, 0.079, 0.082), sr = c(0.592, 0.549, 0.592, 0.549, 0.592, 0.549), condition = c("x1", "x1", "x2", "x2",…
pdubois
  • 7,640
  • 21
  • 70
  • 99
4
votes
2 answers

Plotting predicted survival curves for continuous covariates in ggplot

How can I plot survival curves for representative values of a continuous covariate in a cox proportional hazards model? Specifically, I would like to do this in ggplot using a "survfit.cox" "survfit" object. This may seem like a question that has…
RNB
  • 457
  • 1
  • 5
  • 14
4
votes
1 answer

tidy method of testing model parameters

I would like to compare model performance for a bunch of models using the same predictors but different model parameters. This seems like the place to use broom to create a tidy output, but I can't figure it out. Here's some non-working code that…
AmeliaMN
  • 787
  • 1
  • 8
  • 9
4
votes
1 answer

R ttest looping over grouping variable using tidy

I have seen very similar questions to this but still can't figure this simple problem out. I want to run paired t-tests over a grouping variable and store the results in a dataframe. The command tidy in package broom does this but when I run the…
user63230
  • 4,095
  • 21
  • 43
4
votes
1 answer

R: function to apply Anova over different subsets of one's dataset and collect output

A common task is to have to carry out a certain statistical analysis (like an anova, glm or mixed model) on different subsets of a dataset and combine the output tables with summary coefficients and p values in a single dataframe. I am looking…
user2999576
  • 41
  • 1
  • 6
3
votes
2 answers

broom::tidy and dplyr::group_modify in R: Loping functions across variables grouped by species

I am trying to get a data frame of t.test outputs grouped by species for many variables. I have a subset of data that looks like this; structure(list(Species = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L), levels…
Dustin
  • 183
  • 7
3
votes
1 answer

unable to load shared object 'TMB.so'

I installed broom.mixed package via conda conda install -c conda-forge r-broom.mixed, however, it doesn't import and shows error message: library(broom.mixed) Error: package or namespace load failed for ‘broom.mixed’: .onLoad failed in…
Ramon
  • 63
  • 7
3
votes
0 answers

R: Passing a list of model objects to broom::glance with purrr produces unexpected errors

I am trying to extract information using broom::glance() from survey models. While I can extract coefficients and other model results from each object using broom:tidy(), I sometimes receive an error that the object I am passing does not exist when…
socialscientist
  • 3,759
  • 5
  • 23
  • 58
3
votes
0 answers

Error "No tidy method for objects of class felm" when using the lfe and broom package

I'm trying to tidy the results of my fixed effects linear regression model. Here's the FELM: model_fit <- felm( dependent_variable ~ independent_variable1 + independent_variable2 + independent_variable3 + …
3
votes
1 answer

How to shorten the code in broom while running multiple regression in R?

I am running multiple regressions by different groups. I want to automate things a bit more. I tried to run and save the regressions model1, model2 and model3 initially. Then i tried to shorten the code as the following: temp <- df %>% …
Jack
  • 813
  • 4
  • 17
3
votes
2 answers

How to extract LME4 output to latex tables?

I usually use modelsummary() or stargazer() for extracting tables to latex in R. However, they seem to not work with lme4. Does someone know a way to extract this reproducible example to a nice latex table? Here is my model: df <- tibble( y =…
Jack
  • 813
  • 4
  • 17
1 2
3
22 23