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

Augment with newdata works with one model fails with another

I'm missing something so fundamental here -- why does augment work with one model but not another? data(iris) library(broom) iris$cSepal.Length <- scale(iris$Sepal.Length, center = TRUE, scale = FALSE) nd <- expand.grid(Sepal.Length = seq(4, 8,…
atiretoo
  • 1,812
  • 19
  • 33
2
votes
1 answer

Adding an column for the category of glm coeffients in broom results

Is there any way to add a column to the result of the broom package's tidy function that can act relate the term column back to both the original names used in the formula argument and their columns in the data argument. For example if I run the…
guyabel
  • 8,014
  • 6
  • 57
  • 86
2
votes
0 answers

extracting prediction on new leveled dataset using augment

I am running regression on data by group/levels. so a reg for each level, i.e, my code looks very similar to this: library('dplyr') regressions <- mtcars %>% group_by(cyl) %>% do(mod = lm(mpg ~ wt, .)) How do I extract predictions on a smaller…
Alice Work
  • 185
  • 1
  • 2
  • 10
2
votes
1 answer

combine t-test results into a dataframe with broom

I'm trying to repeatedly sample two vectors, x and y, 100 times and compute a t-test after each sample. I then want to combine the results into a dataframe using the broom package. My attempt at doing this is below. However, all I've managed to do…
luciano
  • 13,158
  • 36
  • 90
  • 130
1
vote
1 answer

Extract pValue of slopes from a linear model using the tidyverse and add it to a plot

This relates to a previously asked question about fitting a linear or sloped model of gene expression data. I have expression values of various genes during 5 consecutive development stages and want to create a linear model to test of the genes…
Sebastian Hesse
  • 542
  • 4
  • 16
1
vote
2 answers

How to use broom::tidy for Tobit models?

Dear Stackoverflow community, I am struggling with using the tidy function from the broom package. I need this function in the context of a multiple imputation. You can see here a reprex example using a ggplot2 dataset. library(ggplot2, quietly =…
HuMaN90
  • 13
  • 2
1
vote
0 answers

How to pool results from multinomial logistic regression across multiple imputations using MICE

I am trying to pool results from a multinomial logistic regression across multiple imputations using the mice package, but I am getting this error: No tidy method recognized for this list. I have tried loading the broom.mixed package instead of the…
meghanborg
  • 11
  • 2
1
vote
1 answer

In R how do you loop ANOVA and post-hoc Tukey tests through several variables and capture summaries in a data frame?

I have data that looks like this; df <- data.frame(Treat = rep(LETTERS[1:4], 100, replace = TRUE), A = rnorm(400), B = rnorm(400), C = rnorm(400), D = rnorm(400), E…
Dustin
  • 183
  • 7
1
vote
1 answer

How to extract adjusted r squared values from multiple linear models run in a loop with tidy() and do()

I found this cool piece of code in the posit community but I cannot ask a follow up question so I am coming here. I would like to get the adjusted r-squared value from this 'loop' but I cannot manage to do so, so I decided to ask the group. The code…
Natz
  • 77
  • 6
1
vote
1 answer

Error: No glance method recognized for this list

I'm trying to write a function that can flexibly group by a variable number of arguments and fit a linear model to each subset. The output should be a table with each row showing the grouping variable(s) and corresponding lm call results that…
Jaywalker
  • 49
  • 5
1
vote
2 answers

make nice simple t-test (difference in means) table that can be exported to latex in R

The biggest problem with using methods such as through library(broom) library(dplyr) library(broom) output <- iris %>% group_by(Species) %>% summarise(tidy(t.test(Sepal.Width))) Is that it produces a tibble which is essentially a glorified…
1
vote
1 answer

How to use dplyr pipe to perform linear model

I have the following data frame: library(broom) library(tidyverse) dat <- structure(list(x = c(800, 400, 200, 100, 50), y = c(605, 467, 323, 219, 110)), row.names = c(NA, -5L), class = c("tbl_df", "tbl", "data.frame")) dat That looks like this: #…
littleworth
  • 4,781
  • 6
  • 42
  • 76
1
vote
2 answers

Removing GOF in texreg with fixest library's feols regression object in R

I am using feols from the fixest library in R and then texreg / htmlreg to create tables. I would like to exclude several Goodness of Fit measures from my table (AIC, BIC, loglikelihood, etc), but texreg interprets my regression as an object form…
Márton
  • 35
  • 2
1
vote
1 answer

How to implement "broom" package in R

I have an issue that might be silly in some ways, but following this question: Linear Regression and group by in R I tried to install the broom package in order to "retrieve the coefficients and Rsquared/p.value". I know that the previous question…
Recology
  • 165
  • 1
  • 10
1
vote
1 answer

How to export margins of odered logit model from R to latex?

I am running an ordered logit model using the package: oglmx After running the regression, I calculated the margins using: oglmx.margins. However, I cannot export this output to latex or word or excel. I have tried stargazer, export_summs, and…
Akshara
  • 11
  • 2