[R] Error in gam?
Hadley Wickham
h.wickham at auckland.ac.nz
Sun Apr 18 22:57:38 CEST 2004
I'm having some problems using variable names containing spaces (using
backticks) with gam (mgcv 0.9-6, R 1.8.1). Some toy code to reproduce
my problem is below. Am I doing something wrong, or should I pass this
bug on to Simon Wood? (Or do I need to rename my variables to get rid of
the spaces?)
Thanks,
Hadley
library(mgcv)
test <- data.frame(a = c(1:10), `a b` = c(1:10)^2, c=2:11, check.names=F)
test$`a b`
lm(a ~ `a b`, data=test) #works
gam(a ~ s(c), data=test) #works
gam(a ~ s(`a b`), data=test) #error below
Error in parse(file, n, text, prompt) : parse error
traceback()
9: parse(text = x)
8: eval(parse(text = x)[[1]])
7: formula(eval(parse(text = x)[[1]]))
6: switch(mode(x), "NULL" = structure(NULL, class = "formula"),
character = formula(eval(parse(text = x)[[1]])), call = eval(x),
stop("invalid formula"))
5: formula.default(object, env = NULL)
4: formula(object, env = NULL)
3: as.formula(rf)
2: gam.parser(formula)
1: gam(a ~ s(`a b`), data = test)
More information about the R-help
mailing list