Skip to content

🖱️⚔️ R package: off-label concepts for executing R code from links in the console, using {cli}

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

matt-dray/choosethis

Repository files navigation

{choosethis}

Project Status: Concept – Minimal or no implementation has been done yet, or the repository is only intended to be a limited example, demo, or proof-of-concept. Blog post

Demonstrations of using {cli} to present clickable links to the user in their console. Read more in the accompanying blogpost.

Demos

You can install {choosethis} from GitHub.

if (!require(remotes)) install.packages("remotes")
install_github("matt-dray/choosethis")
library(choosethis)

1. Text adventure

To start a new game:

begin()
You reach a fork in the road.
* Go left
* Go right

If your console supports links (e.g. RStudio), then the words ‘left’ and ‘right’ in the printout will be clickable (not shown above). Click one and you’ll be taken to the next choice. If unsupported, you’ll be shown functions to copy-paste yourself.

2. Summarise a data.frame

To begin:

ask_col_mean(ChickWeight)
What column would you like the mean of?
* weight
* Time

If your console supports links (e.g. RStudio), then the column names in the printout (weight, Time) will be clickable (not shown above). Click one and you’ll be returned the mean value for that column.

Theory

The {cli} package lets you present clickable ANSI links to the user in supported terminals, such as RStudio.

choosethis::begin() uses cli::ansi_has_hyperlink_support() to discover whether a user’s terminal can support these links. If links aren’t supported, then the underlying expression will be presented to the user instead of a clickable link.

About

🖱️⚔️ R package: off-label concepts for executing R code from links in the console, using {cli}

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Languages