Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions R/prepare_boxly.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ prepare_boxly <- function(meta,
observation = NULL,
analysis = NULL,
filter_var = "PARAM",
hover_var_outlier = c("USUBJID", metalite::collect_adam_mapping(meta, analysis)$y)) {
hover_var_outlier = c("USUBJID", metalite::collect_adam_mapping(meta, analysis)$y),
mean_decimal = NULL) {
if (is.null(population)) {
if (length(meta$population) == 1) {
population <- meta$population[[1]]$name
Expand Down Expand Up @@ -179,7 +180,11 @@ prepare_boxly <- function(meta,
ans$min <- vals[1]
ans$q1 <- vals[2]
ans$median <- vals[3]
ans$mean <- mean_val
if (!is.null(mean_decimal)) {
ans$mean <- round(mean_val, mean_decimal)
} else {
ans$mean <- mean_val
}
ans$q3 <- vals[4]
ans$max <- vals[5]

Expand Down
37 changes: 37 additions & 0 deletions vignettes/testing-format-statistics.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "Untitled"
author: "Jeetender Singh Chauhan"
date: "`r Sys.Date()`"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```



```{r , echo=FALSE}
library(metalite)
library(boxly)

# Step 1: Source your modified prepare_boxly.R file
# (Update the path to where your modified file is saved)
source("~/boxly_format_mean_value/R/prepare_boxly.R")

# Step 2: Create metadata
meta <- meta_boxly(
boxly_adsl,
boxly_adlb,
population_term = "apat",
observation_term = "wk12"
)

# Step 3: Prepare data with 2 decimal places for mean
outdata <- prepare_boxly(meta, mean_decimal = 5)

# Step 4: Generate the interactive box plot
boxly(outdata)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Loading