Create a WebR REPL sharelink from R code
webr_repl_link.Rd
Generates a shareable URL for R code that can be executed in the webR environment. The code is compressed, base64-encoded, and embedded in the URL.
Usage
webr_repl_link(
code,
filename = "script.R",
path = NULL,
autorun = FALSE,
mode = NULL,
version = "latest",
base_url = NULL
)
Arguments
- code
Character string containing R code to share
- filename
Name for the file (default:
"script.R"
)- path
Full path where the file will be placed in WebR (default:
"/home/web_user/{filename}"
)- autorun
Logical. Whether to auto-execute the code when link is opened (default:
FALSE
)- mode
Character vector or string specifying which WebR interface components to show. Valid components:
"plot"
,"files"
,"terminal"
,"editor"
. Can bec("plot", "files")
or"plot-files"
. If NULL (default), shows all components.- version
WebR version to use (
"latest"
or specific version >= "v0.5.4")- base_url
WebR application URL. If NULL, uses global option or builds from version
Examples
# Simple code sharing
code <- "plot(1:10)"
link <- webr_repl_link(code, autorun = TRUE)
# Show only plot and editor
link <- webr_repl_link(code, mode = c("plot", "editor"))
# String format for mode
link <- webr_repl_link(code, mode = "plot-files-terminal")
# Custom path and version with mode
link <- webr_repl_link(code,
path = "/tmp/my_script.R",
mode = c("editor", "terminal"),
version = "v0.5.4")