[R] groupedData constructor with generated formula: Error in inherits(formula,"formula")

Dieter Menne dieter.menne at menne-biomed.de
Wed Jul 3 18:01:41 CEST 2002


Dear List,

I want to generate the formula in the groupedData constructor
from a string. It works ok (see oxg2) outside of a function,
but fails in a function environment.
What wrong with my example below?

Dieter

----------------------------

library(nlme)
data(Oxboys)
# make it a normal data frame
ox<-as.data.frame(Oxboys)

#works ok
oxg2<-groupedData(as.formula("height~age|Subject"),data=ox)


ProcessPar<-function(par)
{
  form1<-as.formula(paste(par,"~age|Subject"))
  form1
  inherits(form1,"formula") # TRUE
  oxg3<-groupedData(form1,data=ox)
  # do further processing with oxg3
}
# does not work:
ProcessPar("height")

#Error in inherits(formula, "formula") :
#  Object "form1" not found
traceback()
#5: inherits(formula, "formula")
#4: nfGroupedData(formula = form1, data = ox)
#3: do.call("nfGroupedData", mCall)
#2: groupedData(form1, data = ox)
#1: ProcessPar("height")


---------------------------------------
Dr. Dieter Menne
Biomed Software
72074 Tübingen
Tel (49) (7071) 52176
FAX (49) (7071) 55 10 46
dieter.menne at menne-biomed.de
www.menne-biomed.de



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list