moshagen / semPower

R package providing a-priori, post-hoc, and compromise power analyses for structural equation models (SEM)
7 stars 3 forks source link

fix issue with supplying arguments to genLambda #6

Closed martinabader closed 1 year ago

martinabader commented 1 year ago

When extracting objects from a list using the $ operator, R does not seem to match all characters of the name of the object.

For example: args <- list(nIndicator = rep(3,4), loadMinMax = c(.5, .6)) args$loadM [1] 0.5 0.6 # extracts loadMinMax because the first characters are the same

args[['loadM']] NULL # this works

This issue caused problems with input validation in genLambda if(!is.null(loadMinMax) && (!is.null(loadM) || !is.null(loadSD))) stop('Either specify mean and SD of loadings or specify min-max loading, both not both.')

moshagen commented 1 year ago

Argh. Partial matching is the root of all evil. We'll need to check the remaining parts of the code and replace any usage of $x for lists with [[x]] to avoid that changes introduce hard to find bugs.