Skip to content

Commit

Permalink
Merge pull request #46 from priism-center/dev
Browse files Browse the repository at this point in the history
updated clean detect ID
  • Loading branch information
gperrett committed Dec 14, 2023
2 parents 52184f2 + 8724ff1 commit f1b634b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions thinkCausal/R/fct_clean.R
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ clean_detect_integers <- function(x, n_levels_threshold = 15){
#' ID detection is based on column name and the values. If none are detected, then columns are categorized as 'X'
#'
#' @param .data a dataframe
#' @param z string indicating named of selected treatment
#' @param y string indicating name of selected response
#'
#' @author Joe Marlo & George Perrett
#'
Expand All @@ -249,11 +251,11 @@ clean_detect_integers <- function(x, n_levels_threshold = 15){
#' )
#' clean_detect_ID_column(.data)

clean_detect_ID_column <- function(.data) {
clean_detect_ID_column <- function(.data, z, y) {

# set list of potential column names to match
ID_potentials <- c("^id")
all_col_names <- colnames(.data)
all_col_names <- colnames(.data)[colnames(.data) %notin% c(z, y)]

# find ID columns
ID_matches <- sapply(X = all_col_names, FUN = function(col){
Expand Down
4 changes: 2 additions & 2 deletions thinkCausal/R/fct_create.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#' @return html
#'
#' @noRd
create_drag_drop_roles <- function(ns, .data, ns_prefix, exclude = NULL, include_all = FALSE, blocks = FALSE,random_effect = FALSE, weight = FALSE, default_weight = NULL, default_random_effects = NULL,default_blocks = NULL){
create_drag_drop_roles <- function(ns, .data, ns_prefix, exclude = NULL, include_all = FALSE, blocks = FALSE,random_effect = FALSE, weight = FALSE, default_weight = NULL, default_random_effects = NULL,default_blocks = NULL, z = NULL, y = NULL){
if (!inherits(.data, 'data.frame')) stop('.data must be a dataframe')
# search for an ID variable
auto_columns <- clean_detect_ID_column(.data)
auto_columns <- clean_detect_ID_column(.data, z, y)

# gather coviraiate names
if(isFALSE(include_all)){
Expand Down
4 changes: 4 additions & 0 deletions thinkCausal/R/mod_analysis_variable_selection.R
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ mod_analysis_variable_selection_server <- function(id, store){

drag_drop_html <- create_drag_drop_roles(ns = ns,
.data = store$analysis_data_uploaded_df,
z = input$analysis_select_treatment,
y = input$analysis_select_outcome,
ns_prefix = 'analysis_select',
exclude = .exclude,
include_all = input$analysis_select_include_all,
Expand All @@ -402,6 +404,8 @@ mod_analysis_variable_selection_server <- function(id, store){
return(drag_drop_html)
})


# reactive function to run checks over selected varaibles
check_variable_assignment <- reactive({
# remove any previous dataframes from the store
store <- remove_downstream_data(store, page = 'select')
Expand Down

0 comments on commit f1b634b

Please sign in to comment.