Giter Club home page Giter Club logo

Comments (12)

DominiqueMakowski avatar DominiqueMakowski commented on May 8, 2024 2

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.

mattansb avatar mattansb commented on May 8, 2024 1

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.

pdwaggoner avatar pdwaggoner commented on May 8, 2024 1

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.

pdwaggoner avatar pdwaggoner commented on May 8, 2024 1

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.

DominiqueMakowski avatar DominiqueMakowski commented on May 8, 2024 1

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.

strengejacke avatar strengejacke commented on May 8, 2024

I vote for @pdwaggoner suggestion, as the word "install" only appears once (and not three times in two sentences).

from easystats.

mattansb avatar mattansb commented on May 8, 2024

I second that!

from easystats.

strengejacke avatar strengejacke commented on May 8, 2024

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.

DominiqueMakowski avatar DominiqueMakowski commented on May 8, 2024

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.

strengejacke avatar strengejacke commented on May 8, 2024

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.

DominiqueMakowski avatar DominiqueMakowski commented on May 8, 2024

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.

IndrajeetPatil avatar IndrajeetPatil commented on May 8, 2024

I think this can be closed?

from easystats.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.