Comments (6)
Unfortunately bootstrap
hasn't worked with summarize
in a while (it did when the function was originally written, but stopped being compatible after a dplyr update/improvement). It relies on a manipulation of the group indices that is consistent with do
but not summarize
.
My understanding is that bootstrapping in the future should probably be done with the lowliner package, which has some very slick solutions for this kind of problem; I just haven't investigated it yet. The main reason bootstrap
is in the package is to cover the cases in the broom manuscript (and I'm certainly open to pull requests that would improve it).
In the meantime you could also work around it with do
:
mtcars %>% bootstrap(10) %>% do(data.frame(mean = mean(.$mpg)))
from broom.
Thanks, that's great to know! I was wondering what you plan might be for broom::bootstrap
. Thanks very much for making that PR to modelr, hopefully that'll make modelr::bootstrap
a bit easier to use. Great to see resampling methods becoming easy to implement in the tidyverse, thanks again!
from broom.
Thanks for the workaround David. I will look into the lowliner package as well. Thanks for the tip.
Vincent
—
Sent from Mailbox
On Sun, Feb 1, 2015 at 8:37 PM, David Robinson [email protected]
wrote:
Unfortunately
bootstrap
hasn't worked withsummarize
in a while (it did when the function was originally written, but stopped being compatible after a dplyr update/improvement). It relies on a manipulation of the group indices that is consistent withdo
but notsummarize
.
My understanding is that bootstrapping in the future should probably be done with the lowliner package, which has some very slick solutions for this kind of problem; I just haven't investigated it yet. The main reasonbootstrap
is in the package is to cover the cases in the broom manuscript (and I'm certainly open to pull requests that would improve it).
In the meantime you could also work around it withdo
:mtcars %>% bootstrap(10) %>% do(data.frame(mean = mean(.$mpg)))
Reply to this email directly or view it on GitHub:
https://github.com/dgrtwo/broom/issues/25#issuecomment-72405484
from broom.
I also stumbled into this recently. Fortunately we now also have a bootstrap
in @hadley's modelr
, as well as the excellent purrr
package (formerly lowliner), and we can do something like this with the above example:
library(dplyr)
library(purrr)
library(modelr)
mtcars %>%
modelr::bootstrap(10) %>%
mutate(mean_mpg = map_dbl(strap, ~mean(data.frame(.)$mpg)))
# A tibble: 10 × 3
strap .id mean_mpg
<list> <chr> <dbl>
1 <S3: resample> 01 20.26875
2 <S3: resample> 02 19.89062
3 <S3: resample> 03 19.20000
4 <S3: resample> 04 19.79062
5 <S3: resample> 05 19.50625
6 <S3: resample> 06 19.19063
7 <S3: resample> 07 19.40625
8 <S3: resample> 08 21.53125
9 <S3: resample> 09 19.84375
10 <S3: resample> 10 20.97812
I was a little surprised about the need to coerce the resample
object in the strap
column to a data frame in order to access the mpg
column. Is that intentional?
from broom.
Yes, I'm generally recommending people use modelr's bootstrap rather than broom's now. Once modelr is stable and on CRAN I will deprecate broom::bootstrap.
As for needing to do as.data.frame(): a resample object is more like a promise of a data frame than an actual one (though not technically a promise
) and only creates the object when requested. It has recently occurred to me that we should really have $
or [[]]
evaluate as well and I plan on submitting a modelr pull request to that effect soon!
from broom.
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
from broom.
Related Issues (20)
- tidy.varest contains wrong (repeated) coefficients? HOT 4
- transition to cli errors
- add / polish alt text
- Regression Model Accuracy Metrics for Objects of class oohbchoice HOT 2
- No tidy method for objects of class npregression HOT 2
- Issues regarding CI computing for lm.beta models HOT 2
- augment error with `na.action = na.exclude` in `lm` HOT 1
- add conf.int and exponentiate arguments to `tidy.cch()`
- Error: No tidy method for objects of class npregression HOT 2
- Possible bug with `tidy() ` function on `lm.beta` object HOT 3
- augment() fails HOT 3
- address GHA failures re: minimum R version HOT 1
- Bug in `tidy.survfit()` coming in the next release of the {survival} pkg HOT 5
- Create tidy method HOT 5
- Support for glmtoolbox (GEE) HOT 2
- Allow choosing the type of residuals in `tidy.betareg()` HOT 3
- GHA failure re: archived package HOT 1
- dependency install errors on GHA HOT 3
- Release broom 1.0.6 HOT 1
- Glance.lm gives does not give fstatistic/ f stat based values when used on a 0 intercept model.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from broom.