Demonstrations of using {cli} to present clickable links to the user in their console. Read more in the accompanying blogpost.
You can install {choosethis} from GitHub.
if (!require(remotes)) install.packages("remotes")
install_github("matt-dray/choosethis")
library(choosethis)
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.
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.
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.