mlr-org / mlr

Machine Learning in R
https://mlr.mlr-org.com
Other
1.64k stars 404 forks source link

What to do with the purrr pkg? #2489

Closed pat-s closed 5 years ago

pat-s commented 5 years ago

Bernd raised the question on Slack. https://cran.r-project.org/web/packages/purrr/index.html purrr deps:

Imports: magrittr (≥ 1.5), rlang (≥ 0.1), tibble
Suggests: covr, dplyr (≥ 0.7.5), knitr, rmarkdown, testthat
mllg commented 5 years ago

The complete list of dependencies:

 setdiff(package_dependencies("purrr", recursive=TRUE)[[1L]], getOption("defaultPackages"))
 [1] "magrittr"   "rlang"      "tibble"     "cli"        "crayon"    
 [6] "pillar"     "assertthat" "fansi"      "utf8"       "tools" 

Here is a simple replacement for imap (without the NSE for obvious reasons):

imap = function(.x, .f) {
  Map(.f, .x = .x, .y = seq_along(.x))
}
mllg commented 5 years ago

For map_xxx we have the v[ilnc]apply alternatives in BBmisc.

I'm not saying that I generally don't like the purrr package, but I believe we should either use it everywhere or stick to the previously used apply functions.

pat-s commented 5 years ago

Here is a simple replacement for imap (without the NSE for obvious reasons):

cool.

For map_xxx we have the v[ilnc]apply alternatives in BBmisc.

I'm not saying that I generally don't like the purrr package, but I believe we should either use it everywhere or stick to the previously used apply functions.

Yes. Let's see if I can get rid of them then.

The complete list of dependencies:

Meta questions:

mllg commented 5 years ago

Meta questions:

  • Would you consider this amount as "many"?
  • The question is anyhow if these deps are so "heavy" bc a normal R user nowadays has all of these deps installed via other pkgs anyway?

I guess it is a tradeoff. You don't want to reinvent the wheel, but http://www.tinyverse.org/ also got some arguments.

For some wrappers around lapply, purrr looks quite heavy.

  • should we rely on purrr in mlr3?

Are you suggesting to import purrr and replace all calls to lapply/vapply/mapply/... with their purrr counterparts? :wink:

pat-s commented 5 years ago

http://www.tinyverse.org/ also got some arguments.

Nice reference.

Are you suggesting to import purrr and replace all calls to lapply/vapply/mapply/... with their purrr counterparts? wink

I guess I do not need an answer for this anymore ;)

The point I had is that using pkgs that are widely known to the com make it way easier for people to contribute bc you do not have to tell them "have a look at our 999+ helper functions in pkg X that we wrote because base-R sucks and dependencies even more".