permalink2list {businessPlanR}R Documentation

Turn a Shiny permalink into a list

Description

The Shiny package can generate permalinks of its web apps, making it possible to share individual configurations of the app with others. This function translated such a permalink into a named list, so you can use the configuration also in R code.

Usage

permalink2list(permalink, prefix = ".*\\?_inputs_&")

Arguments

permalink

Character string, the actual URL with arguments copied from the Shiny app as-is.

prefix

Character string or regular expression, should capture everything up to the first argument name. This is the part that will be discarded.

Details

When this package was written, we also wrote a Shiny web app for it but separated the actual calculations from the app's code. This allowed us to use the same functions and objects in RMarkdown. We were discussing the numbers in the web tool using permalinks, and finally transferred the calculations to the PDF version.

To transfer the configuration from the web app to the markdown document, this function discards the URL prefix and splits the arguments into a named list that behaves like the input object commonly used in Shiny apps.

Value

A named list with one element for each argument in permalink.

Examples

permalink2list(
  paste0(
    "https://example.com/businessPlanR/?_inputs_&salary=50000",
    "&loan_interest=3.22&loan_period=7&loan_due=2&years=%5B%222022%22%2C%222026%22%5D"
  )
)

[Package businessPlanR version 0.1-0 Index]