Skip to content

Devr 3528 proper case race interactive baseline char tbl issue86 #99

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

Merged
35 changes: 32 additions & 3 deletions vignettes/interactive-baseline.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ adsl$TRTA <- factor(adsl$TRTA,
labels = c("Placebo", "Low Dose", "High Dose")
)

meta <- meta_adam(
meta_sl <- meta_adam(
population = adsl,
observation = adsl
) |>
Expand Down Expand Up @@ -85,13 +85,42 @@ In this vignette, we will directly use the metadata built by `meta_ae_example()`
meta_ae <- meta_ae_example()
```

## Customization (Optional)

If you want to capitalize only the first letter of "RACE" (e.g., Black or african american) or any other character variable,
you can customize the `react_base_char` function at the beginning of the code.


```{r}
# function to capitalize the first letter of a string that has multiple words
capitalize_words <- function(x) {
sapply(x, function(word) {
paste0(toupper(substr(word, 1, 1)), tolower(substr(word, 2, nchar(word))))
})
}
```

```{r}
# 1) In "data_population": extract the RACE values as a character vector
race_values_pop <- meta_sl[["data_population"]]$RACE # Use $ to get a vector

# Capitalize the race values
meta_sl[["data_population"]]$RACE <- capitalize_words(race_values_pop) # Assign back as a vector

# 2) In "data_observation": extract the RACE values as a character vector
race_values_obs <- meta_sl[["data_observation"]]$RACE # Use $ to get a vector

# Capitalize the race values
meta_sl[["data_observation"]]$RACE <- capitalize_words(race_values_obs) # Assign back as a vector
```

# Build a reactable {.tabset}

## Baseline characteristic table + Participants With Drug-Related AE

```{r, eval = TRUE}
react_base_char(
metadata_sl = meta,
metadata_sl = meta_sl,
metadata_ae = meta_ae,
ae_subgroup = c("age", "race", "gender"),
ae_specific = "rel",
Expand All @@ -103,7 +132,7 @@ react_base_char(

```{r, eval=TRUE}
react_base_char(
metadata_sl = meta,
metadata_sl = meta_sl,
metadata_ae = meta_ae,
ae_subgroup = c("age", "race", "gender"),
ae_specific = "ser",
Expand Down