Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use shinylive to show the app on the README #1490

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ coverage.*
^.revdeprefs\.yaml$
^revdep$
^\.covrignore$
^README\.Rmd$
30 changes: 30 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,38 @@ on:
workflow_dispatch:

jobs:
README:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/[email protected]
with:
fetch-depth: 0

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2

- uses: r-lib/actions/setup-r-dependencies@v2

- name: Render Rmarkdown files 🖹
run: |
RMD_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} *.Rmd))
Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f)' ${RMD_PATH[*]}

- name: Commit results ⬆️
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git commit ${RMD_PATH[*]/.Rmd/.md} -m 'Re-build Rmarkdown files' || echo "No changes to commit"
git push origin || echo "No changes to commit"
docs:
name: Pkgdown Docs 📚
needs: README
uses: insightsengineering/r.pkg.template/.github/workflows/pkgdown.yaml@main
secrets:
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.3.9003
hooks:
- id: readme-rmd-rendered
name: Render README.md
- id: style-files
name: Style code with `styler`
args:
Expand Down
170 changes: 170 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# `teal`: Interactive Exploratory Data Analysis with `Shiny` Web-Applications <a href='https://insightsengineering.github.io/teal/'><img src="man/figures/logo.svg" align="right" height="139" style="max-width: 100%; max-height: 139px;"/></a >

<!-- start badges -->
[![CRAN Version](https://www.r-pkg.org/badges/version/teal?color=green)](https://cran.r-project.org/package=teal)
[![Total Downloads](http://cranlogs.r-pkg.org/badges/grand-total/teal?color=green)](https://cran.r-project.org/package=teal)
[![Last Month Downloads](http://cranlogs.r-pkg.org/badges/last-month/teal?color=green)](https://cran.r-project.org/package=teal)
[![Last Week Downloads](http://cranlogs.r-pkg.org/badges/last-week/teal?color=green)](https://cran.r-project.org/package=teal)

[![Check 🛠](https://github.com/insightsengineering/teal/actions/workflows/check.yaml/badge.svg)](https://insightsengineering.github.io/teal/main/unit-test-report/)
[![Docs 📚](https://github.com/insightsengineering/teal/actions/workflows/docs.yaml/badge.svg)](https://insightsengineering.github.io/teal/)
[![Code Coverage 📔](https://raw.githubusercontent.com/insightsengineering/teal/_xml_coverage_reports/data/main/badge.svg)](https://insightsengineering.github.io/teal/main/coverage-report/)

![GitHub forks](https://img.shields.io/github/forks/insightsengineering/teal?style=social)
![GitHub repo stars](https://img.shields.io/github/stars/insightsengineering/teal?style=social)

![GitHub commit activity](https://img.shields.io/github/commit-activity/m/insightsengineering/teal)
![GitHub contributors](https://img.shields.io/github/contributors/insightsengineering/teal)
![GitHub last commit](https://img.shields.io/github/last-commit/insightsengineering/teal)
![GitHub pull requests](https://img.shields.io/github/issues-pr/insightsengineering/teal)
![GitHub repo size](https://img.shields.io/github/repo-size/insightsengineering/teal)
![GitHub language count](https://img.shields.io/github/languages/count/insightsengineering/teal)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Current Version](https://img.shields.io/github/r-package/v/insightsengineering/teal/main?color=purple\&label=package%20version)](https://github.com/insightsengineering/teal/tree/main)
[![Open Issues](https://img.shields.io/github/issues-raw/insightsengineering/teal?color=red\&label=open%20issues)](https://github.com/insightsengineering/teal/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
<!-- end badges -->

`teal` is a `shiny`-based interactive exploration framework for analyzing data. `teal` applications require app developers to specify:

<!-- markdownlint-disable MD007 MD030 -->
- Data, which can be:
- CDISC data, commonly used for clinical trial reporting
- Independent datasets, for example from a `data.frame`
- Related datasets, for example a set of `data.frames` with key columns to enable data joins
- `MultiAssayExperiment` objects which are `R` data structures for representing and analyzing multi-omics experiments
- `teal` modules:
- `teal modules` are `shiny` modules built within the `teal` framework that specify analysis to be performed. For example, it can be a module for exploring outliers in the data, or a module for visualizing the data in line plots. Although these can be created from scratch, many `teal` modules have been released and we recommend starting with modules found in the following packages:
- [`teal.modules.general`](https://insightsengineering.github.io/teal.modules.general/latest-tag/): general modules for exploring relational/independent/CDISC data
- [`teal.modules.clinical`](https://insightsengineering.github.io/teal.modules.clinical/latest-tag/): modules specific to CDISC data and clinical trial reporting
- [`teal.modules.hermes`](https://insightsengineering.github.io/teal.modules.hermes/latest-tag/): modules for analyzing `MultiAssayExperiment` objects

<!-- markdownlint-enable MD007 MD030 -->

A lot of the functionality of the `teal` framework derives from the following packages:

<!-- markdownlint-disable MD007 MD030 -->
- [`teal.data`](https://insightsengineering.github.io/teal.data/latest-tag/): creating and loading the data needed for `teal` applications.
- [`teal.widgets`](https://insightsengineering.github.io/teal.widgets/latest-tag/): `shiny` components used within `teal`.
- [`teal.slice`](https://insightsengineering.github.io/teal.slice/latest-tag/): provides a filtering panel to allow filtering of data.
- [`teal.code`](https://insightsengineering.github.io/teal.code/latest-tag/): handles reproducibility of outputs.
- [`teal.logger`](https://insightsengineering.github.io/teal.logger/latest-tag/): standardizes logging within `teal` framework.
- [`teal.reporter`](https://insightsengineering.github.io/teal.reporter/latest-tag/): allows `teal` applications to generate reports.

Dive deeper into `teal` with our comprehensive video guide.
Please click the image below to start learning:

[![A Complete Guide to Getting Started with teal](https://img.youtube.com/vi/N8ZamECICSI/0.jpg)](https://www.youtube.com/watch?v=N8ZamECICSI)

<!-- markdownlint-enable MD007 MD030 -->

## Installation

```{r, eval=FALSE}
install.packages("teal")
```

Alternatively, you might also use the development version.

```{r, eval=FALSE}
# install.packages("pak")
pak::pak("insightsengineering/teal")
```

## Usage

```{r teal, eval=FALSE}
library(teal)

app <- init(
data = teal_data(iris = iris),
modules = list(
module(
label = "iris histogram",
server = function(input, output, session, data) {
updateSelectInput(
session = session,
inputId = "var",
choices = names(data()[["iris"]])[1:4]
)

output$hist <- renderPlot({
req(input$var)
hist(x = data()[["iris"]][[input$var]])
})
},
ui = function(id) {
ns <- NS(id)
list(
selectInput(
inputId = ns("var"),
label = "Column name",
choices = NULL
),
plotOutput(outputId = ns("hist"))
)
}
)
)
)

shinyApp(app$ui, app$server)
```

![App recording](man/figures/readme_app.webp)


## Try it out in Shinylive

```{r shinylive_url, echo = FALSE, results = 'asis', eval = requireNamespace("roxy.shinylive", quietly = TRUE)}
code <- paste0(c(
knitr::knit_code$get("teal")
), collapse = "\n")

url <- roxy.shinylive::create_shinylive_url(code)
cat(sprintf("[Open in Shinylive](%s)\n\n", url))
```

```{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")}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this condition probably needs some rework
this is very specific to the vigniette that we want to have only in pkgdown website but not in the help panel. I don't think this holds true here.
For instance, I think it's reasonable to expect this to be rendered in the GitHub preview here: https://github.com/insightsengineering/teal/tree/1404_shinylive_readme%40main?tab=readme-ov-file

Copy link
Contributor Author

@llrs-roche llrs-roche Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I'm not sure we can insert iframes on markdown format with knitr. See the error message when I simplified the condition: #1490 (comment). Some sites say iframes are supported while other says it is disabled due to security concerns. But this might be a knitr limitation as I saw some comments about using some flags on pandoc to insert iframes.

In addition, if we want the iframe to show on the pkgdown index.html we need to render it to markdown ourselves as pkgdown won't do it (see this previous comment). But it might take time to do this on the GHA and won't be ready for today's release.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok thanks for the reply. I agree - let's not block the release because of that and let's investigate this afterwards

knitr::include_url(url, height = "800px")
```

Please see [`teal.gallery`](https://insightsengineering.github.io/teal.gallery/) and [TLG Catalog](https://insightsengineering.github.io/tlg-catalog/) to see examples of `teal` apps.

Please start with the ["Technical Blueprint" article](https://insightsengineering.github.io/teal/latest-tag/articles/blueprint/index.html), ["Getting Started" article](https://insightsengineering.github.io/teal/latest-tag/articles/getting-started-with-teal.html), and then other [package vignettes](https://insightsengineering.github.io/teal/latest-tag/articles/index.html) for more detailed guide.

## Getting help

If you encounter a bug or have a feature request, please file an issue. For questions, discussions, and updates, use the `teal` channel in the [`pharmaverse` slack workspace](https://pharmaverse.slack.com).

## Acknowledgment

This package is a result of a joint efforts by many developers and stakeholders. We would like to thank everyone who contributed so far!

## Stargazers and Forkers

### Stargazers over time

[![Stargazers over time](https://starchart.cc/insightsengineering/teal.svg)](https://starchart.cc/insightsengineering/teal)

### Stargazers

[![Stargazers repo roster for @insightsengineering/teal](http://reporoster.com/stars/insightsengineering/teal)](https://github.com/insightsengineering/teal/stargazers)

### Forkers

[![Forkers repo roster for @insightsengineering/teal](http://reporoster.com/forks/insightsengineering/teal)](https://github.com/insightsengineering/teal/network/members)
Loading