Comments (12)
True true, but I liked the idea of providing directly the install code to run 😬
maybe:
stop("Package \"X\" needed for this function to work. Please run 'install.packages(X)'.")
so the user can simply copy paste the thing?
That's a super minor thing though, I am also okay with Hadley's holy Word :)
from easystats.
For readability (and usability) I suggest:
stop("This function requires the package 'X' to be installed.\nPlease install by running 'install.packages(\"X\")' and run the function again ;-)")
#> Error: This function requires the package 'X' to be installed.
#> Please install by running 'install.packages("X")' and run the function again ;-)
from easystats.
For my packages, I just copied Hadley Wickham (usually a safe strategy):
stop("Package \"X\" needed for this function to work. Please install it.")
from easystats.
Ha! Hadley's holy word aside, while its a useful place to start, I like the idea of making this our own as well in line with @DominiqueMakowski suggestion. While the assumption could be made that if they're using our packages then they should already know how to install a package, I like the idea of customizing the warning message for our purposes and goals (i.e., making stats in R easy; this makes good sense to me)
from easystats.
Now that I think of it, the easiest way would be to offer the possibility to automatically install the thing, similarly to what caret or other packages do.
"Package \"X\" needed for this function. Press ENTER to install or ESCAPE to abort."
from easystats.
I vote for @pdwaggoner suggestion, as the word "install" only appears once (and not three times in two sentences).
from easystats.
I second that!
from easystats.
I think such user interaction is more dangerous than useful. Imagine this happens when running scripts, tests, vignettes, markdowns, ... Scripts are frozen until user does something and no error message or whatever is shown.
I do not recommend such actions. And if users don't know how to install a package, they can ask for help somewhere or maybe they're not our (or R's) target group anyway ;-)
from easystats.
Mmmh that's true, although that's why there is the interactive state variable. Usually, the user is prompted and asked to respond only if interactive() == TRUE. Else, the traditional stop
would occur. Do you think it's not a sufficient safeguard against potential issues related to user input?
from easystats.
We could indeed offer this, however, in my experience, in most cases you need to restart the R session because some namespaces are loaded, or installation fails etc. That's why I personally would say a message is enough.
from easystats.
in most cases you need to restart the R session
so true 😩 So yeah now I agree. Still, returning the right install code so that the user can just copy-paste seems useful (I've used that myself quite a lot)
from easystats.
I think this can be closed?
from easystats.
Related Issues (20)
- Don't comment out tests HOT 4
- Evaluate example and vignettes conditionally if they require internet access HOT 3
- About loading packages in tests HOT 11
- Harmonize `README`s across the ecosystem HOT 3
- Use `.R` file extension instead of `.r` HOT 5
- Synchronize GitHub release titles with CRAN releases HOT 3
- Adding links to `see` vignettes in individual packages HOT 1
- Move from GPL-3 to MIT license HOT 8
- Figure out why total download counts are not included in the README table HOT 1
- Namespace error with sjPlot after installing easy stats HOT 3
- Use the new `check_if_installed()` with `.get_dep_version()` in all easystats packages HOT 1
- Should we leave out `date` and `author` from vignette metadata?
- Collect roxygen import tags and re-exports in a single location HOT 2
- Use `\donttest` instead of `\dontrun` tag for skipping examples on CRAN machines HOT 6
- Next meta-package CRAN release HOT 6
- Going workflow green HOT 1
- Surprising behaviour of tests on Windows in some specific contexts HOT 5
- Getting rid of a warning in a vignette HOT 2
- Check that the tests don't change the global state
- Running tests on 2 cores only HOT 6
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 easystats.