Skip to content

Commit

Permalink
Minor bug fixes and release patch version
Browse files Browse the repository at this point in the history
"Closes" #236, #237, #238
  • Loading branch information
Sachin Gaikwad committed May 30, 2024
1 parent 84542e9 commit e9faf42
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
17 changes: 17 additions & 0 deletions R/create_IV.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ create_IV <- function(data,
exc_sig = FALSE,
return = "plot"){

# Input validation
if (!is.data.frame(data)) {
stop("The 'data' parameter should be a data frame.")
}

if (!is.null(predictors) && !all(predictors %in% names(data))) {
stop("Some predictors are not present in the data.")
}

if (!outcome %in% names(data)) {
stop("The outcome variable is not present in the data.")
}

if (!all(data[[outcome]] %in% c(0, 1))) {
stop("The outcome variable should be binary (0 or 1).")
}

# Preserve string ----------------------------------------------------------
pred_chr <- NULL
pred_chr <- predictors
Expand Down
10 changes: 9 additions & 1 deletion R/create_boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ create_boxplot <- function(data,
arrange(desc(mean)) %>%
pull(group)

## x axis label handling
if(hrvar == "Total"){
xlabel<-""
}
else{
xlabel<-hrvar
}

plot_object <-
plot_data %>%
mutate(group = factor(group, levels = group_ord)) %>%
Expand All @@ -147,7 +155,7 @@ create_boxplot <- function(data,
tolower(clean_nm),
"by",
tolower(camel_clean(hrvar)))) +
xlab(hrvar) +
xlab(xlabel) +
ylab(paste("Average", clean_nm)) +
labs(caption = extract_date_range(data, return = "text"))

Expand Down
8 changes: 8 additions & 0 deletions R/create_stacked.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ create_stacked <- function(data,
data %>%
check_inputs(requirements = required_variables)

## Plot Title Handling
if(class(metrics)=="character" & length(metrics)==1){
plot_title <- us_to_space(metrics)
}
else{ #vector of strings
plot_title <- paste(plot_title, collapse = ", ")
}

## Handle `legend_lab`
if(is.null(legend_lab)){
legend_lab <- gsub("_", " ", metrics)
Expand Down

0 comments on commit e9faf42

Please sign in to comment.