Skip to content

Commit

Permalink
Vignette changes (#687)
Browse files Browse the repository at this point in the history
Closes #640

---------

Signed-off-by: Vedha Viyash <[email protected]>
  • Loading branch information
vedhav authored Feb 27, 2024
1 parent 8173007 commit 1fae848
Show file tree
Hide file tree
Showing 22 changed files with 122 additions and 140 deletions.
3 changes: 2 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
linters: linters_with_defaults(
line_length_linter = line_length_linter(120),
cyclocomp_linter = NULL,
object_usage_linter = NULL
object_usage_linter = NULL,
object_name_linter = object_name_linter(styles = c("snake_case", "symbols"), regexes = c(ANL = "^ANL_?[0-9]*$", ADaM = "^r?AD[A-Z]{2,3}_?[0-9]*$"))
)
2 changes: 0 additions & 2 deletions R/tm_g_response.R
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ srv_g_response <- function(id,
env = list(resp_var = resp_var)
)
) %>%
# nolint start
# rowf and colf will be a NULL if not set by a user
teal.code::eval_code(
substitute(
Expand All @@ -433,7 +432,6 @@ srv_g_response <- function(id,
env = list(x_cl = x_cl, rowf = rowf, colf = colf)
)
)
# nolint end

plot_call <- substitute(
expr = ggplot(ANL2, aes(x = x_cl, y = ns)) +
Expand Down
Binary file added vignettes/images/app-teal-modules-general.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vignettes/images/app-using-association-plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vignettes/images/app-using-bivariate-plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vignettes/images/app-using-cross-table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vignettes/images/app-using-data-table.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vignettes/images/app-using-outliers-module.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vignettes/images/app-using-regression-plots.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vignettes/images/app-using-response-plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vignettes/images/app-using-scatterplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 5 additions & 6 deletions vignettes/teal-modules-general.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The concepts presented here require knowledge about the core features of `teal`,
application and how to pass data into it. Therefore, it is highly recommended to refer to the [`README`](https://insightsengineering.github.io/teal/index.html) file and
the introductory [vignette](https://insightsengineering.github.io/teal/latest-tag/articles/teal.html) of the `teal` package.

See also `teal.modules.clinical's` [`README`](https://insightsengineering.github.io/teal.modules.clinical/latest-tag/index.html).
See also `teal.modules.clinical`'s [`README`](https://insightsengineering.github.io/teal.modules.clinical/latest-tag/index.html).

### Main features

Expand All @@ -38,12 +38,11 @@ See [package functions / modules](https://insightsengineering.github.io/teal.mod

### Example application

A simple application including a `tm_variable_browser` module could look like this:
A simple application including a `tm_variable_browser()` module could look like this:
```{r, message = FALSE, results = "hide"}
library(teal.modules.general)
library(teal.widgets)
# nolint start
data <- teal_data()
data <- within(data, {
ADSL <- teal.modules.general::rADSL
Expand All @@ -52,7 +51,6 @@ data <- within(data, {
datanames <- c("ADSL", "ADTTE")
datanames(data) <- datanames
join_keys(data) <- default_cdisc_join_keys[datanames]
# nolint end
app <- init(
data = data,
Expand All @@ -71,9 +69,12 @@ app <- init(
shinyApp(app$ui, app$server)
```

<img src="images/app-teal-modules-general.png" style = "display: block; margin: 0px; width: 100%"/>

Let's break the above app into pieces:
```r
library(teal.modules.general)
library(teal.widgets)
```
The line mentioned above imports the library required for this example and loads data from within that library.

Expand All @@ -85,7 +86,6 @@ so both the code and data are stored together.
Following this, we set the `datanames` and `join_keys`.

```r
# nolint start
data <- teal_data()
data <- within(data, {
ADSL <- teal.modules.general::rADSL
Expand All @@ -94,7 +94,6 @@ data <- within(data, {
datanames <- c("ADSL", "ADTTE")
datanames(data) <- datanames
join_keys(data) <- default_cdisc_join_keys[datanames]
# nolint end
```

There is no need to load `teal` as `teal.modules.general` already depends on it.
Expand Down
49 changes: 17 additions & 32 deletions vignettes/using-association-plot.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ vignette: >

# `teal` application to use association plot with various datasets types

This vignette will guide you through 4 parts to create a teal application using
various types of datasets inside an association plot module:
This vignette will guide you through the four parts to create a teal application using
various types of datasets using the association plot module `tm_g_association()`:

1. Load Libraries
2. Create data sets
3. Create an `app` variable
4. Run the App

## Loading libraries
## 1 - Loading libraries

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"}
library(teal.modules.general) # used to create the app
library(dplyr) # used to modify data sets
```

## Create data sets
## 2 - Create data sets

Inside this app 5 datasets will be used

Expand All @@ -37,30 +37,6 @@ Inside this app 5 datasets will be used
5. `ADLB` A long data set with lab measurements for each subject

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"}
# nolint start
ADSL <- teal.modules.general::rADSL
ADSL2 <- teal.modules.general::rADSL %>%
mutate(TRTDUR = round(as.numeric(TRTEDTM - TRTSDTM), 1))
ADRS <- teal.modules.general::rADRS
ADTTE <- teal.modules.general::rADTTE
ADLB <- teal.modules.general::rADLB %>%
mutate(CHGC = as.factor(case_when(
CHG < 1 ~ "N",
CHG > 1 ~ "P",
TRUE ~ "-"
)))
# nolint end
```

## Initialize an app

This is the most important section. We will use the [`teal::init`](https://insightsengineering.github.io/teal/latest-tag/reference/init) function to
create an app. The data will be handed over using [`teal.data::cdisc_data`](https://insightsengineering.github.io/teal.data/latest-tag/reference/cdisc_data). The app
itself will be constructed by multiple calls of `tm_g_association` using different
combinations of data sets.

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"}
# nolint start
data <- teal_data()
data <- within(data, {
ADSL <- teal.modules.general::rADSL
Expand All @@ -82,9 +58,17 @@ jk_adsl2 <- jk
names(jk_adsl2)[names(jk_adsl2) == "ADSL"] <- "ADSL2"
jk <- c(jk, jk_adsl2)
jk["ADSL2", "ADSL"] <- c("USUBJID", "STUDYID")
join_keys(data) <- jk
```

# nolint end
## 3 - Create an `app` variable

This is the most important section. We will use the `teal::init` function to
create an app. The data will be handed over using `teal.data::teal_data`. The app
itself will be constructed by multiple calls of `tm_g_association()` using different
combinations of data sets.

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"}
app <- init(
data = data,
modules = modules(
Expand Down Expand Up @@ -301,12 +285,13 @@ app <- init(
)
```

## Run the app
## 4 - Run the app

A simple `shiny::shinyApp` call will let you run the app.
Note that app is only displayed when running this code inside an R session.
Note that app is only displayed when running this code inside an R session.

```{r echo=TRUE}
```{r, echo=TRUE, results="hide"}
shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024))
```

<img src="images/app-teal-modules-general.png" style = "display: block; margin: 0px; width: 100%"/>
27 changes: 13 additions & 14 deletions vignettes/using-bivariate-plot.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,23 @@ vignette: >

# `teal` application to use bivariate plot with various datasets types

This vignette will guide you through 4 parts to create a teal application using
various types of datasets inside an bivariate plot module:
This vignette will guide you through the four parts to create a teal application using
various types of datasets using the bivariate plot module `tm_g_bivariate()`:

1. Load Libraries
2. Create data sets
3. Create an `app` variable
4. Run the App



## Loading libraries
## 1 - Loading libraries

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"}
library(teal.modules.general) # used to create the app
library(dplyr) # used to modify data sets
```


## Create data sets
## 2 - Create data sets

Inside this app 5 datasets will be used

Expand All @@ -40,7 +38,6 @@ Inside this app 5 datasets will be used
5. `ADLB` A long data set with lab measurements for each subject

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"}
# nolint start
data <- teal_data()
data <- within(data, {
ADSL <- teal.modules.general::rADSL
Expand All @@ -62,14 +59,14 @@ jk_adsl2 <- jk
names(jk_adsl2)[names(jk_adsl2) == "ADSL"] <- "ADSL2"
jk <- c(jk, jk_adsl2)
jk["ADSL2", "ADSL"] <- c("USUBJID", "STUDYID")
# nolint end
join_keys(data) <- jk
```

## Create an `app` variable
## 3 - Create an `app` variable

This is the most important section. We will use the [`teal::init`](https://insightsengineering.github.io/teal/latest-tag/reference/init) function to
create an app. The data will be handed over using [`teal.data::cdisc_data`](https://insightsengineering.github.io/teal.data/latest-tag/reference/cdisc_data). The app
itself will be constructed by multiple calls of `tm_g_bivariate` using different
This is the most important section. We will use the `teal::init` function to
create an app. The data will be handed over using `teal.data::teal_data`. The app
itself will be constructed by multiple calls of `tm_g_bivariate()` using different
combinations of data sets.

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"}
Expand Down Expand Up @@ -606,11 +603,13 @@ app <- init(
```


## Run the app
## 4 - Run the app

A simple `shiny::shinyApp` call will let you run the app.
Note that app is only displayed when running this code inside an R session.

```{r echo=TRUE}
```{r, echo=TRUE, results="hide"}
shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024))
```

<img src="images/app-using-bivariate-plot.png" style = "display: block; margin: 0px; width: 100%"/>
24 changes: 12 additions & 12 deletions vignettes/using-cross-table.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,29 @@ vignette: >

# `teal` application to use cross table with various datasets types

This vignette will guide you through 4 parts to create a teal application using
various types of datasets inside an cross table module:
This vignette will guide you through the four parts to create a teal application using
various types of datasets using the cross table module `tm_t_crosstable()`:

1. Load Libraries
2. Create data sets
3. Create an `app` variable
4. Run the App

## Loading libraries
## 1 - Loading libraries

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"}
library(teal.modules.general) # used to create the app
library(dplyr) # used to modify data sets
```

## Create data sets
## 2 - Create data sets

Inside this app 2 datasets will be used

1. `ADSL` A wide data set with subject data
2. `ADLB` A long data set with lab measurements for each subject

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide", echo=2:6}
# nolint start
data <- teal_data()
data <- within(data, {
ADSL <- teal.modules.general::rADSL
Expand All @@ -48,14 +47,13 @@ data <- within(data, {
datanames <- c("ADSL", "ADLB")
datanames(data) <- datanames
join_keys(data) <- default_cdisc_join_keys[datanames]
# nolint end
```

## Create an `app` variable
## 3 - Create an `app` variable

This is the most important section. We will use the [`teal::init`](https://insightsengineering.github.io/teal/latest-tag/reference/init) function to
create an app. The data will be handed over using [`teal.data::cdisc_data`](https://insightsengineering.github.io/teal.data/latest-tag/reference/cdisc_data). The app
itself will be constructed by multiple calls of `tm_t_crosstable` using different
This is the most important section. We will use the `teal::init` function to
create an app. The data will be handed over using `teal.data::teal_data`. The app
itself will be constructed by multiple calls of `tm_t_crosstable()` using different
combinations of data sets.

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"}
Expand Down Expand Up @@ -129,11 +127,13 @@ app <- init(
)
```

## Run the app
## 4 - Run the app

A simple `shiny::shinyApp` call will let you run the app.
Note that app is only displayed when running this code inside an R session.

```{r echo=TRUE}
```{r, echo=TRUE, results="hide"}
shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024))
```

<img src="images/app-using-cross-table.png" style = "display: block; margin: 0px; width: 100%"/>
24 changes: 12 additions & 12 deletions vignettes/using-data-table.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ vignette: >
%\VignetteEncoding{UTF-8}
---

# `teal` application to use association plot with various datasets types
# `teal` application to display data table with various datasets types

This vignette will guide you through 4 parts to create a teal application using
various types of datasets inside a data table module:
This vignette will guide you through the four parts to create a teal application using
various types of datasets using the data table module `tm_data_table()`:

1. Load Libraries
2. Create data sets
3. Create an `app` variable
4. Run the App

## Loading libraries
## 1 - Loading libraries

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"}
library(teal.modules.general) # used to create the app
```

## Create data sets
## 2 - Create data sets

Inside this app 3 datasets will be used

Expand All @@ -34,7 +34,6 @@ Inside this app 3 datasets will be used
3. `ADLB` A long data set with lab measurements for each subject

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"}
# nolint start
data <- teal_data()
data <- within(data, {
ADSL <- teal.modules.general::rADSL
Expand All @@ -44,13 +43,13 @@ data <- within(data, {
datanames <- c("ADSL", "ADTTE", "ADLB")
datanames(data) <- datanames
join_keys(data) <- default_cdisc_join_keys[datanames]
# nolint end
```

## Create an `app` variable
## 3 - Create an `app` variable

This is the most important section. We will use the [`teal::init`](https://insightsengineering.github.io/teal/latest-tag/reference/init) function to
create an app. The data will be handed over using [`teal.data::cdisc_data`](https://insightsengineering.github.io/teal.data/latest-tag/reference/cdisc_data). The app itself will be constructed by multiple calls of `tm_data_table` using different
This is the most important section. We will use the `teal::init` function to
create an app. The data will be handed over using `teal.data::teal_data`.
The app itself will be constructed by multiple calls of `tm_data_table()` using different
combinations of data sets.

```{r echo=TRUE, message=FALSE, warning=FALSE, results="hide"}
Expand Down Expand Up @@ -99,12 +98,13 @@ app <- init(
)
```

## Run the app
## 4 - Run the app

A simple `shiny::shinyApp` call will let you run the app.
Note that app is only displayed when running this code inside an R session.

```{r echo=TRUE}
```{r, echo=TRUE, results="hide"}
shinyApp(app$ui, app$server, options = list(height = 1024, width = 1024))
```

<img src="images/app-using-data-table.png" style = "display: block; margin: 0px; width: 100%"/>
Loading

0 comments on commit 1fae848

Please sign in to comment.