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

Fit different data for each row of a list-columns data frame

suppressPackageStartupMessages(library(dplyr)) library(gapminder) library(magrittr) library(ggplot2) library(broom) fits <- gapminder %>% group_by(country) %>% do(fit = lm(lifeExp ~ year +pop, .)) result<-fits %>% augment(fit) result I…
gilberke
  • 45
  • 1
  • 7
1
vote
1 answer

Plotting line shapefile on ggmap using fortify () or broom::tidy() producing a polygon-like output

I am plotting a shapefile into a googlemap using ggmap and broom::tidy function to fortify it (convert to a dataframe), but for some reason the line shapefile appears as a polygon on the google map. I have no idea what is causing it. The shapefile…
MIH
  • 1,083
  • 3
  • 14
  • 26
1
vote
1 answer

r: select(everything()) not working with broom::augment for modeling results

I am looking to create a clean dataframe with reodered columns out of a linear model results lm, my eventual aim is to write the dataframe to excel to chart and audit model residuals. First, the sample data: df1 <- cbind.data.frame(dt =…
dre
  • 474
  • 5
  • 19
1
vote
2 answers

R Capturing regression slopes by group in a dataframe

My dataframe consists of scores for different questions asked in a survey, over 3 fiscal years (FY13, FY14 & FY15). The results are presented by Region. Here's what a sample of the actual dataframe looks like, where we have two questions per region,…
Varun
  • 1,211
  • 1
  • 14
  • 31
1
vote
2 answers

Comparing multiple variables in more than two groups with t.test

I tried to do a t-test comparing values between time1/2/3.. and threshold. here is my data frame: time.df1<-data.frame("condition" =c("A","B","C","A","C","B"), "time1" = c(1,3,2,6,2,3) , "time2" = c(1,1,2,8,2,9) , "time3" =…
Hanscot
  • 77
  • 8
1
vote
2 answers

Using Group by and Slope with dplyr to get new column

I'm looking for a more direct solution using dplyr to get a column titled slope from my data. The data set is grouped by season and stat type. My current code is: library(tidyverse); library(broom) full_table_raw <- structure(list(playerID =…
Jazzmatazz
  • 615
  • 7
  • 18
1
vote
1 answer

Can results of models fit to multiply imputed datasets be extracted to a dataframe?

Is it possible to extract to a dataframe the pooled estimates from several models fit to multiply imputed data? Below is how I perform this for a complete case dataframe (i.e. with no missing data) - I would like to do a similar process to extract…
aelhak
  • 441
  • 4
  • 14
1
vote
1 answer

Predicting values with dplyr and augment

I'd like to fit models to a grouped data frame and then predict one new value per model (i.e. group). library(dplyr) library(broom) data(iris) dat <- rbind(iris, iris) dat$Group <- rep(c("A", "B"), each = 150) new.dat <- data.frame(Group =…
erc
  • 10,113
  • 11
  • 57
  • 88
1
vote
1 answer

Calculating slope and associated stats by rows using multiple categories in dataframe that has NAs

I have looked at related questions posted under: "How can I calculate the slope of multiple subsets of a data frame more efficiently?" and my beginner status doesn't allow me to comment on that thread directly (not sure how to do that), so I ask…
Mary
  • 41
  • 5
1
vote
0 answers

Mapping auto.arima() to list of subset timeseries

I have a list of timeseries data like this: > str(ffz2$time_series) List of 89 $ 1_1 : Time-Series [1:47] from 2013 to 2017: 6.95 7.03 7.06 7.03 7.09 ... $ 1_10 : Time-Series [1:47] from 2013 to 2017: 7.1 7.13 7.12 7.13 7.21 ... $ 1_2 :…
Davide Lorino
  • 875
  • 1
  • 9
  • 27
1
vote
1 answer

R- One way anova extracting p_value

I'm trying to do a one-way anova on several row of a dataset and extract the p_value to use it afterwards. Here's what i've done: anova <- function(x) {summary(aov(x ~ bt.factor))[[1]]["Pr(>F)"]} anv.pval <- apply(golubALL, 1, anova) With this…
Solal
  • 13
  • 4
1
vote
1 answer

Extract only the forecasted values from forecast()

I have a dataframe that looks like this: > head(forecasts) $`1_1` Point Forecast Lo 80 Hi 80 Lo 95 Hi 95 Dec 2016 7.370299 7.335176 7.405422 7.316583 7.424015 $`1_10` Point Forecast Lo 80 Hi 80 Lo 95 …
Davide Lorino
  • 875
  • 1
  • 9
  • 27
1
vote
1 answer

Functional Vector Arithmetic on Nested Data Frames

I would like to create a function that returns a vector - the vector needs to contain the sum of values in another vector (monthly_amount), but only sums the values in 'monthly_amount' for the corresponding 'year_month' (a third vector) to the index…
Davide Lorino
  • 875
  • 1
  • 9
  • 27
1
vote
0 answers

Error using broom::tidy on a linear mixed model created with lmerTest

I am trying to use the tidy function in the broom R package to display results from a linear mixed model created with lmer from lmerTest. I get an error and I don't know if it's from a bug or incorrectly using the library. Perhaps this isn't…
tkerwin
  • 9,559
  • 1
  • 31
  • 47
1
vote
1 answer

extract rowwise_df regressions to display using texreg

inspired by SO this answer I'm using teh do dplyr to perform several regressions at once, I would however like to display my output using texreg and do() produces a rowwise_df object, but if I extract the list of regression some information seem to…
Eric Fail
  • 8,191
  • 8
  • 72
  • 128