Comments (7)
I could imagine that library()
could have an ask = interactive()
default argument indicating whether to ask the user if they want to install, such that: library("pkg")
would fail during non-interactive mode, prompt during interactive mode by default, and not prompt interactively if set explicitly to false (i.e., library("pkg", ask = FALSE)
.
from wishlist-for-r.
pacman::p_load()
does this.
from wishlist-for-r.
This is not a general solution for R or something I would recommend those new to the language to use, but https://github.com/jimhester/autoinst when used as an error handler will automatically install missing packages for you when they throw an error. It also queries GitHub for R packages if the missing package is not on CRAN, so like I said, not a general solution.
from wishlist-for-r.
There are probably several attempts to work around this out there. Here are the ones I am aware of (please let me know of others):
pacman::p_load()
replaceslibrary()
w/install.packages()
iff needed.R.utils::use()
- replaceslibrary()
andloadNamespace()
w/install.packages()
iff needed.
Last updated: 2016-04-27
from wishlist-for-r.
@HenrikBengtsson I really don't think we want an option-based approach here. Mostly because I don't want an option-based approach anywhere really (there are some exceptions). Code that does radically different things based on things external to both code and explicit inputs? No thank you.
I'd say adding an argument is more reasonable. I could see library(, install=) working, though we'd need to think hard about what the default to that should be. I suspect you'll want it to be TRUE, but I'm not sure the case for that is as strong as it might appear (network roundtrip and attempted install in the case of typo ...).
from wishlist-for-r.
Another usecase could be pkg::foo()
. In that case there is no explicit function call where we can specify an install
argument.
I agree that options should not be over/misused, but in some cases I find them really handy. In this case I'd argue that the behavior is more related to the UI rather than function (with stringsAsFactors
being extreme example of what we don't want). I don't see how the end results would differ with and without automatic package installation, expect from a time delay.
I also think it is important not to enforce package installation on people, e.g. poor/expensive internet access. This is why I believe it has to be an option.
from wishlist-for-r.
I would argue fairly strongly that pkg::foo() should not install a package, even if library did. I don't think those are interchangeable enough; ::
is (semantically, if not implementation-wise) a strict namespacing operation. ::
is also used in package code (whether this is good, bad or mixed is an open question and not the topic of discussion here) so we're talking about unexpected installation. The same goes for the require*
functions, which would damage how use of suggested packages works now.
So I'd say if this was done, it really should only be done for library, and as an argument.
I guess my deeper question is whether this is really a major annoyance to people? As far as I know, other interpreted languages (python, julia, etc) don't do this, though I must admit I haven't looked.
from wishlist-for-r.
Related Issues (20)
- WISH: `drop` = FALSE by default for `[.data.frame` HOT 9
- Fast check for discreteness
- Make UTF-8 the default encoding for package metadata HOT 2
- WISH/ROBUSTNESS: Mechanism to prevent var <<- value from assigning non-existing 'var' HOT 1
- Consistency: fix matrix subsetting behaviour to be consistent with vectors and data.frames.
- Base R function for length(unique(x))
- WISH: Standardized SystemRequirements HOT 1
- `grDevices::dev.capabilities()` enhancements
- Permit larger seed argument values in set.seed() HOT 1
- Wish: base version of glue::glue() HOT 3
- Add predict method for `stats::kmeans()`
- R CMD check: Option for reporting on writes/updates to tools::R_user_dir() during checks HOT 1
- R CMD check: Option for testing with empty tools::R_user_dir() folders
- Control over `NA` equality in `base::rle()`
- WISH: Make serverSocket(0) useful (+ find a random TCP port that can be listened to) HOT 1
- Task & browser hooks to support implementation of a debug adapter protocol client
- parallel: A sequential cluster
- parallel: Two types of 'cluster':s - one a subclass of the other HOT 1
- WISH: `load()` to have an option to bust saved unevaluated promise objects (`PROMSXP`) HOT 2
- WISH: Customizable print method for character vector with long text
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 wishlist-for-r.