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

Extend create_table() #118

Merged
merged 19 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: clinsight
Title: ClinSight
Version: 0.1.0.9004
Version: 0.1.0.9005
Authors@R: c(
person("Leonard Daniël", "Samson", , "[email protected]", role = c("cre", "aut"),
comment = c(ORCID = "0000-0002-6252-7639")),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

S3method(create_table,adverse_events)
S3method(create_table,bm_cytology)
S3method(create_table,common_events)
S3method(create_table,conc_procedures)
S3method(create_table,continuous)
S3method(create_table,default)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Generalized `merge_meta_with_data()` to allow user-defined processing functions.
- Added a feature where, in applicable tables, a user can navigate to a form by double-clicking a table row.
- Fixed warnings in `apply_edc_specific_changes` due to the use of a vector within `dplyr::select`.
- Added form type as a class to be used in `create_table()` to display tables.

# clinsight 0.1.0

Expand Down
13 changes: 10 additions & 3 deletions R/fct_appdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,13 @@ get_appdata <- function(
meta = metadata
){
tableclasses <- gsub("create_table.", "", as.character(utils::methods("create_table")))
var_levels <- dplyr::distinct(meta$items_expanded, item_name, item_group)
var_levels <- dplyr::distinct(meta$items_expanded, item_name, item_group)
forms <- c("common_forms", "study_forms", "general")
form_types <- Map(
\(x, y) cbind(form_type = y, item_group = unique(x$item_group)),
metadata[forms],
forms) |>
do.call(what = rbind.data.frame)

data <- split(data, ~item_group)
## Apply changes specific for continuous data:
Expand All @@ -267,9 +273,10 @@ get_appdata <- function(
"item_group consists of multipe elements which is not allowed: ",
item_group_x
)
class(x) <- c(with(form_types, form_type[item_group == item_group_x]), class(x))
tableclass <- simplify_string(item_group_x)
if(tableclass %in% tableclasses){
class(x) <- c(tableclass, class(x))
class(x) <- unique(c(tableclass, class(x)))
LDSamson marked this conversation as resolved.
Show resolved Hide resolved
}
if(!all(x$item_type == "continuous")) return(x)
df <- x |>
Expand Down Expand Up @@ -312,7 +319,7 @@ get_appdata <- function(
)
) |>
dplyr::ungroup()
class(df) <- c("continuous", class(df))
class(df) <- unique(c("continuous", class(x)))
LDSamson marked this conversation as resolved.
Show resolved Hide resolved
df
})
appdata
Expand Down
17 changes: 17 additions & 0 deletions R/fct_tables.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,23 @@ create_table.general <- function(
}


#' Create Default 'Common Events' Table
#'
#' @export
#' @inherit create_table.default
create_table.common_events <- function(
jthompson-arcus marked this conversation as resolved.
Show resolved Hide resolved
data,
name_column = "item_name",
value_column = "item_value",
keep_vars = c("subject_id", "form_repeat"),
expected_columns = NULL,
...
){
create_table.default(data, name_column, value_column,
keep_vars, expected_columns)
}


#' Create Adverse Events table
#'
#' Function to create an adverse event dataset.
Expand Down
1 change: 1 addition & 0 deletions inst/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ reference:
- create_table.default
- create_table.adverse_events
- create_table.bm_cytology
- create_table.common_events
- create_table.conc_procedures
- create_table.continuous
- create_table.general
Expand Down
41 changes: 41 additions & 0 deletions man/create_table.common_events.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading