From erich.neuwirth at univie.ac.at  Tue Aug 23 00:45:02 2005
From: erich.neuwirth at univie.ac.at (Erich Neuwirth)
Date: Tue, 23 Aug 2005 00:45:02 +0200
Subject: [Rd] Questions about calls and formulas
In-Reply-To: <40e66e0b05082214525e2140e8@mail.gmail.com>
References: <430A4629.8010506@univie.ac.at>
	<40e66e0b05082214525e2140e8@mail.gmail.com>
Message-ID: <430A556E.4080203@univie.ac.at>

> 
>>(foo <- eval(substitute(x ~ g * h, list(x = as.name("weights")))))
> 
> weights ~ g * h
> 
>>class(foo)
> 
> [1] "formula"
> 
> 

  ff<-formula("x~g*h")
  (foo<-eval(substitute(ff,list(x=as.name("weights")))))

gives

  x ~ g * h

what needs to be done to ff for the substitution to work?

I found a way of doing it using string substitution
and applying formula (instead of as.call) to the string,
but I would like to be able to do it using substitution.

This is what I currently do:

  myexpr<-paste("weights ~",strsplit(deparse(m$formula),"~")[[1]][2])
  m$formula<-formula(myexpr)


-- 
Erich Neuwirth, Didactic Center for Computer Science
University of Vienna
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39902 Fax: +43-1-4277-9399



[Rd] Questions about calls and formulas
Erich Neuwirth