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)
- Allow subdirectories in the R directory (R packages) HOT 6
- .DollarNames auto completion inside brackets
- Drop inconsolata as default code font in pdf vignettes
- Support for decorators HOT 5
- Have a global option to change the temporary directory HOT 2
- Underscore `_` as digit separator HOT 2
- bug in setting `warnPartialMatchDollar`? HOT 9
- WISH: Add an R option to control argument 'type' of demo(..., type = c("console", "html"))
- WISH: allow for longer file path lengths under Windows HOT 3
- docstrings HOT 8
- CONSISTENCY: Add CLI argument --expr=EXPR complementing -e EXPR
- WISH: attr() allows to provide a default fallback value HOT 4
- Rscript -e EXPR fails to launch if stdin is closed HOT 3
- Suggested performance improvements in R HOT 1
- Separate Build-depends: from Suggests: in DESCRIPTION files HOT 9
- Allow setting breakpoints from debugger
- 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
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.