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

Access the estimate inside a model object in R

I am running a simulation and would like to know if there was a way to access the "x" estimate inside of my model using broom, dplyr, modelr, or purrr. This gives me exactly what I want, but I don't want to use [[1]] in the last chunk of…
Alex
  • 2,603
  • 4
  • 40
  • 73
0
votes
1 answer

Is there a way to catch both Coefficient and R-squared using Broom?

I'm looping trough several regressions and aim to have a final result with different models, their respective coefficients and statistics, and some general results, as adjusted r squared, AIC and etc. This looping is done considering some subgroups…
Elijah
  • 414
  • 3
  • 8
0
votes
1 answer

building multiple models per group

I'd like to group my data, then build two linear models per group, gather the results, and use broom to summarize the model parameters, but I'm having an infinite recursion error that I cant seem to understand. Here's the…
kmace
  • 1,994
  • 3
  • 23
  • 39
0
votes
0 answers

how to achieve the same result with sparklyr on a spark dataframe as with dplyr on an R dataframe?

The following code calculates a set of regression coefficients for each of three dependent variables regressed on the set of six independent variable for each of two groups and it works fine. library(tidyverse) library(broom) n <- 20 df4 <-…
0
votes
0 answers

broom, regressions for subgroups: How to deal with error in reg a subgrup?

I am using dplyr + the broom package to run separate regression for each subgroup in my my_data %>% group_by(my_groups) %>% do(tidy(lm( attended_school ~ treated + I_post_treatmet, data=.) )) (the actuall data is of restricted…
LucasMation
  • 2,408
  • 2
  • 22
  • 45
0
votes
1 answer

How to construct a vector based on lognormal parameters

I have the following vector: foo <- c(1.376, 1.132, 0.828, 0.88, 1.124, 0.955, 1.292, 0.995, 1.207, 1.076, 1.085, 1.061, 0.918, 1.097, 1.505, 1.141, 1.001, 0.927, 1.339, 1.07, 1.332, 0.951, 0.969, 0.904, 0.89, 0.942, 1.141, 0.798, 0.856, 0.819,…
neversaint
  • 60,904
  • 137
  • 310
  • 477
0
votes
1 answer

GLM Parse Categorical Coefficients

I'm trying to create tidy data and I am attempting separating a charter value from the field name #Example: data(mtcars) library(broom) #Adding some new character variables mtcars1 <- mtcars mtcars1$has_leter_yn <- ifelse(grepl("[[:digit:]]" …
Ryan John
  • 1,410
  • 1
  • 15
  • 23
0
votes
1 answer

Choosing arguments in tidy

In a SpatialDataFrame I have the following structure for the data. > str(shapedata_trans@data) 'data.frame': 4066 obs. of 6 variables: $ OBJECTID : num 1 2 3 4 5 6 7 8 9 10 ... $ PC4 : Factor w/ 4066 levels "1011","1012",..: 1 2 3 4 5 6…
zwep
  • 1,207
  • 12
  • 26
0
votes
2 answers

How to first group_by() then iterate lm() through columns?

Let's say we have a data frame with a set of 3 dependent variables and 6 independent variables tagged by a grouping variable. An example of this format is generated with the sample code below: library(tidyverse) library(broom) n <- 15 df <-…
0
votes
1 answer

felm doesn't work with broom::augment/purrr but works with tidy

I'm trying to run regressions within a nested data frame as described here. For my purposes, I'm using felm from the lfe package because I have many levels of fixed effects. If I re-do the example in the link above using felm instead of lm, it…
wytham
  • 98
  • 6
0
votes
1 answer

r fortify in ggplot and tidy in broom package not accepting regions

I can't get either ggplot's fortify or broom's tidy to include regions, even if I load the maptools library as suggested in another post. I start by loading a bunch of libraries, including maptools (0.8-41), rgeos (0.3-22), broom (0.4.1) and…
JerryN
  • 2,356
  • 1
  • 15
  • 49
0
votes
1 answer

List-columns in tibbles: Can I link a list-column with another list-column?

This is my first post, so please excuse me if I sound silly or the answer I am looking for already exists. My main problem is this: I have created a tibble containing 4 columns (a character column, two data columns and a column containing a distance…
Kostas_k84
  • 41
  • 2
0
votes
0 answers

Using R package broom causes error in ifelse

I used R package broom for getting my results as data.frame from lm(). This worked well, but causes problem with my ifelse command. Script that worked well before installing the broom package is following: df$newvariable <- ifelse((df$oldvariable ==…
J5H
  • 21
  • 3
0
votes
1 answer

problems with augment and ggplot on list in R

my data set is: mydata <- data.frame( x1= as.factor(1:3), x2= as.factor (4:6), x3= as.factor(7:9), x4= as.factor (2:7), x5= as.factor(1:6), x6= as.numeric(1:18), x7= as.numeric(18:35) ) I want to do a spline on x6 and x7, but…
memy
  • 229
  • 1
  • 2
  • 8
0
votes
1 answer

Comparing models with dplyr and broom::glance: How to continue if error is produced?

I would like to run each variable in a dataset as a univariate glmer model using the lme4 package in R. I would like to prepare the data with the dplyr/tidyr packages, and organize the results from each model with the broom package (i.e.…
Kevin
  • 229
  • 3
  • 9
1 2 3
22
23