From a5d679ee924433e03e29f55b96a815a18164d29a Mon Sep 17 00:00:00 2001 From: Vedha Viyash <49812166+vedhav@users.noreply.github.com> Date: Wed, 12 Feb 2025 21:38:46 +0530 Subject: [PATCH] docs: add shinylive to the getting started vignette (#1491) Part of #1404 --- vignettes/getting-started-with-teal.Rmd | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/vignettes/getting-started-with-teal.Rmd b/vignettes/getting-started-with-teal.Rmd index 365f0e3c4..472dab474 100644 --- a/vignettes/getting-started-with-teal.Rmd +++ b/vignettes/getting-started-with-teal.Rmd @@ -29,7 +29,11 @@ More advanced users of the framework can also create new analysis modules which This simple `teal` application takes the `iris` and `mtcars` datasets and displays their contents: -```{r message=FALSE, warning=FALSE} +```{r setup, include=FALSE} +library(teal) +``` + +```{r app} library(teal) app <- init( @@ -81,6 +85,17 @@ Every `teal` application is composed of the following elements, all of which can * Filter Panel _(panel on the right hand side)_: for filtering the data to be passed into all `teal` modules. * In the example code: the filter panel is being initialized with a filter for the `Species` variable in the `iris` dataset. +## Try the above app in `shinylive` + +```{r shinylive_iframe, echo = FALSE, out.width = '150%', out.extra = 'style = "position: relative; z-index:1"', eval = requireNamespace("roxy.shinylive", quietly = TRUE) && knitr::is_html_output() && identical(Sys.getenv("IN_PKGDOWN"), "true")} +code <- paste0(c( + "interactive <- function() TRUE", + knitr::knit_code$get("app") +), collapse = "\n") +url <- roxy.shinylive::create_shinylive_url(code) +knitr::include_url(url, height = "800px") +``` + ## Creating your own applications The key function to use to create your `teal` application is `init`, which requires two mandatory arguments: `data` and `modules`. There are other optional arguments for `init`, which can be used to customize the application. Please refer to the documentation for `init` for further details.