Skip to content

Commit da7413f

Browse files
Fix generate_alpha_test_single function: Add default value for adj.vars parameter
- Added adj.vars = NULL as default parameter to prevent missing argument error - Updated formula construction logic to handle NULL adj.vars properly - Fixed issue where function would fail when adj.vars was not provided - All three scenarios now work correctly: 1. adj.vars not provided (uses default NULL) 2. adj.vars explicitly set to NULL 3. adj.vars provided with actual variables - Tested with quick verification script to ensure functionality This resolves the same type of issue found in generate_beta_change_test_pair function.
1 parent 7942958 commit da7413f

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

R/generate_alpha_test_single.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ generate_alpha_test_single <-
6868
time.var = NULL,
6969
t.level = NULL,
7070
group.var,
71-
adj.vars) {
71+
adj.vars = NULL) {
7272

7373
if (is.null(alpha.name)){
7474
return()
@@ -123,10 +123,12 @@ generate_alpha_test_single <-
123123
)
124124

125125
# Create a formula for lm
126+
formula_vars <- group.var
127+
if (!is.null(adj.vars)) {
128+
formula_vars <- c(adj.vars, group.var)
129+
}
126130
formula <-
127-
as.formula(paste0(names(merged_df)[2], "~", paste(c(
128-
adj.vars, group.var
129-
), collapse = "+")))
131+
as.formula(paste0(names(merged_df)[2], "~", paste(formula_vars, collapse = "+")))
130132

131133
# Run lm and create a coefficient table
132134
lm.model <- lm(formula, data = merged_df)

0 commit comments

Comments
 (0)