Dear List,

I'm trying to create a formula method, allowing for a "special"
character in the formula (i.e., similar to for example the gam package
with the character "s" in y ~ s(x)). I've checked and it seems this is
done through attr(,"specials"). However, the section of code below (as
an example extracted from the gam package) gives me an error as shown at
the end. Evidently I'm missing something here...any help is much
appreciated. 

Thanks,
Leo.

"gam2.slist" <-
c("s", "lo", "random")

"gam2" <-
  function(formula, family = gaussian, data, 
           weights, subset, na.action, start = NULL, etastart, mustart,
control = gam.control(...),
           model = FALSE, method="glm.fit", x = FALSE, y = TRUE, ...)
{
  call <- match.call()
  mf <- match.call(expand.dots = FALSE)
  m <- match(c("formula", "data", "subset", "weights", "na.action", 
               "etastart", "mustart", "offset"), names(mf), 0)
  mf <- mf[c(1, m)]
  mf$drop.unused.levels <- TRUE
  mf[[1]] <- as.name("model.frame")
  mt <- if(missing(data)) terms(formula, gam2.slist) else
terms(formula,gam2.slist,data = data)
  mf$formula<-mt

  mf <- eval(mf, parent.frame())
  
  }

set.seed(1)
x <- runif(1000)
y <- runif(1000)
dd <- data.frame(y, x)

g <- gam2(y ~ s(x), data =dd)
Error in eval(expr, envir, enclos) : could not find function "s"
_______________________________________________________________________

This email may be privileged and/or confidential, and the
sender does not waive any related rights and obligations.
Any distribution, use or copying of this email or the
information it contains by other than an intended recipient
is unauthorized. If you received this email in error,
please advise the sender (by return email or otherwise)
immediately. You have consented to receive the attached
electronically at the above-noted email address; please retain a
copy of this confirmation for future reference.

Ce courriel est confidentiel et protégé. L'expéditeur ne renonce
pas aux droits et obligations qui s'y rapportent. Toute diffusion,
utilisation ou copie de ce courriel ou des renseignements qu'il
contient par une personne autre que le (les) destinataire(s)
désigné(s) est interdite. Si vous recevez ce courriel par erreur,
veuillez en aviser l'expéditeur immédiatement, par retour de courriel
ou par un autre moyen. Vous avez accepté de recevoir le(s) document(s)
ci-joint(s) par voie électronique à l'adresse courriel indiquée ci-dessus;
veuillez conserver une copie de cette confirmation pour les fins de reference 
future.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to