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
1
vote
0 answers

Why doesn't 'Tidy' in Broom work as intended for an epi.2by2 object?

I am using the package epiR to calculate measures of association (rate ratio and attributable risk). Results are outputted to a list. I want to get these estimates into one overall dataframe - I thought Broom could do this - see here. This is what I…
MegPophealth
  • 149
  • 1
  • 10
1
vote
1 answer

Group by and pairwise hypothesis testing with the first group on the same column

Let's say I have mtcars dataset with columns mpg and cyl. mpg cyl 21.0 6 21.0 6 22.8 4 21.4 6 18.7 8 18.1 6 I would like to calculate all t.test() (or wilcox.test()) statistics between group where cyl == 4 and others groups. Results…
mihagazvoda
  • 1,057
  • 13
  • 23
1
vote
0 answers

Can I purge data from model objects in R?

I am estimating a large number of models (lm-type, but possibly others) in r. I do this ion a secure server, from which data export is restricted. I am allowed to export the results from models (coefficients, statistics) but not the individual-level…
torkildl
  • 168
  • 8
1
vote
2 answers

Extract residuals from models fit in purrr

I grouped my data and fit a model to each group and I would like to have the residuals for each group. I can see the residuals for each model with RStudio's viewer, but I cannot figure out how to extract them. Extracting one set of residuals can be…
Nazer
  • 3,654
  • 8
  • 33
  • 47
1
vote
1 answer

Tidy or unnest S4 BFBayesFactor object

I want to run several nested t.test and ttestBF (using tidyr::nest()) but I can't manage to either tidy or to unnest the S4: BFBayesFactor object that comes out the ttestBF function. Example data: set.seed(354654) d = tibble(value = rnorm(100), …
niklai
  • 376
  • 3
  • 16
1
vote
2 answers

Is there any way to show results of broom functions in a page?

I was using functions form package broom. But the results span over multiple pages. For example, using mtcars data, I fitted a linear model with model1 <- lm(mpg~. , data=mtcars) # mpg regressed on all other variables of dataset. I want to see the…
Eva
  • 663
  • 5
  • 13
1
vote
1 answer

Unable to install Tidyverse. Broom issues

Whenever I try to install tidyverse in R v 3.6.2 I receive the following error message: Installing package into ‘C:/Users/daeb/Documents/R/win-library/3.6’ (as ‘lib’ is unspecified) also installing the dependency ‘broom’ There is a binary…
Daniel Estévez
  • 113
  • 1
  • 11
1
vote
1 answer

Find predictions for linear model that is grouped_by

I would like to get predicted values based on a model I fit to a training set of data. I have done this before, but now I have a grouping factor and it is throwing me off. I want to predict biomass based on population for each environment.…
Nazer
  • 3,654
  • 8
  • 33
  • 47
1
vote
1 answer

broom::augment omits columns from data

broom::augment outputs only columns from data that are used in formula. This is problematic behavior, because being able to find something like a respondent id can be very helpful at times. Using the newdata argument could be a workaround, but it…
inferator
  • 474
  • 3
  • 12
1
vote
2 answers

Pretty summaries for statistical models

I am looking for a pretty way to see the statistical model summaries in R. In the following example, I want to see cyl_6 or cyl.6 instead of cyl6. How can I do that? library(dplyr) library(broom) mean_mpg <- mean(mtcars$mpg) # creating a new…
Hamideh
  • 665
  • 2
  • 8
  • 20
1
vote
1 answer

T test between two dataframes and grouped by similar rows in R

The title may not be extremely clear but hopefully I can describe it better here. I have two data frames and each one describes monthly spending for different types of customers. For example, for A customers I have a dataframe like year_month …
user2113499
  • 1,001
  • 3
  • 13
  • 23
1
vote
0 answers

Functional programming: use broom nest->tidy->unnest and map within a function

I need to turn a (working) bit of dplyr/broom code into a function, since I'll call it several (dozen) times. I am stuck -- and this has likely to do with Non Standard Evaluation being mixed with Standard Evaluation. Here I take code directly from…
PaoloCrosetto
  • 600
  • 1
  • 7
  • 16
1
vote
1 answer

How to use the predict function for linear models stored in tibbles as columns

I have some code similar to this: library(tidyverse) library(broom) df <- tribble(~group, ~set, ~x, ~y, 0, "training", 1, 2, 0, "training", 2, 4, 0, "training", 4, 9, 0, "training", 5, 9, 0, "training", 15, 29, 0, "training", 20, 42, …
1
vote
1 answer

Using custom function to apply across multiple groups and subsets

I am having trouble trying to apply a custom function to multiple groups within a data frame and mutate it to the original data. I am trying to calculate the percent inhibition for each row of data (each observation in the experiment has a value). …
1
vote
1 answer

arguments provided as a list not getting evaluated properly

I am working on a custom function whose goal is to run a function (..f) for all combinations of grouping variables grouping.var provides for a given dataframe and then tidy those results into a dataframe using broom package. Here is a custom…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51