pbreheny/visreg

parseFormula.R does not correctly handle scaled interaction terms

Opened this issue · 0 comments

If you have scaled interactions fixed effect such as scale(x):scale(y) in the formula, parseFormula.R will not correctly remove both strings.

Expected: x:y
Actual: x):scale(y

Line 17 in parseFormula.R is the relevant snippet to change.

Workaround:
Replace Line 17 with the following lines (will only work for two way interactions - I'm not time rich at the moment to do it properly)

temp <- unlist(strsplit(f[i], ':'))
if(length(temp) == 2) {
  temp <- gsub("\\b[^\\(]*\\(([^,]+).*\\)", "\\1", temp)
  f[i] <- paste(temp[1],temp[2], sep=':')
} else {
 f[i] <- gsub("\\b[^\\(]*\\(([^,]+).*\\)", "\\1", f[i])
}

A real fix should just involve changing the regex string.