Lakens/ANOVApower

Any letter works in strings

Closed this issue · 4 comments

In ANOVA_design(), any letter works in the string, not just w and b. Letters other than w all seem to return a between factor.

ANOVA_design("2F", n = 10, mu = 1:2, sd = 1)
ANOVA_design("2A", n = 10, mu = 1:2, sd = 1)

Also, uppercase W returns a between-factor:

d <- ANOVA_design("2W", n = 100, mu = c(0,0), sd = 1)
d$design   # is 0 and should be 1

Try this to test for a well-formed string (1-3 factors):

pattern <- "^([2-9](w|b)\\*){0,2}[2-9](w|b)$"
grep(pattern, string, ignore.case = TRUE, perl = TRUE)

I have added the following to the ANOVA_design function

#Check String for an acceptable digits and factor (w or b) if (grepl("^(\\d{1,2}(w|b)\\*){0,2}\\d{1,2}(w|b)$", string, ignore.case = FALSE, perl = TRUE) == FALSE) { stop("Problem in the string argument: must input number of levels as integer (2-99) and factor-type (between or within) as lower case b (between) or w (within)") }

I think this code is good but is there any reason to limit the number of factors to 99? The strength of the code is flexibility. Maybe at least allow up to 999?