Maybe most users aren't stupid enough to make this mistake, but if you repeat an element in the condition_names vector, then you just get lots of warnings without an actual description of the error.
It's not a big deal with small datasets because you eventually just see the outcome, but if you're randomizing a large dataset with lots of strata, then you just get lots and lots of the same warning.
Might be a good idea to add a stopifnot(length(unique(condition_names)) == length(condition_names)) or similar?
See example below
> block_var <- rep(c("A", "B","C"), times = c(50, 100, 200))
> Z <- block_ra(block_var = block_var, prob_each = c(1/3, 1/3, 1/3), condition_names = c('C', 'T1', 'T1'))
Warning messages:
1: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels, :
duplicated levels in factors are deprecated
2: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels, :
duplicated levels in factors are deprecated
3: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels, :
duplicated levels in factors are deprecated
4: In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels, :
duplicated levels in factors are deprecated
> table(block_var, Z)
Z
block_var C T1 T1
A 17 33 0
B 34 66 0
C 67 133 0
Warning message:
In `levels<-`(`*tmp*`, value = if (nl == nL) as.character(labels) else paste0(labels, :
duplicated levels in factors are deprecated
In my case, I was randomizing a dataset with a few thousand strata, so my screen just overloaded with warning messages.
Maybe most users aren't stupid enough to make this mistake, but if you repeat an element in the
condition_names
vector, then you just get lots of warnings without an actual description of the error.It's not a big deal with small datasets because you eventually just see the outcome, but if you're randomizing a large dataset with lots of strata, then you just get lots and lots of the same warning.
Might be a good idea to add a
stopifnot(length(unique(condition_names)) == length(condition_names))
or similar?See example below
In my case, I was randomizing a dataset with a few thousand strata, so my screen just overloaded with warning messages.