Thanks for the suggestion, Dennis. Unfortunately, I was not able to make it 
work. Maybe I'm not using as.formula properly. I posted below some new things I 
tried. What am I doing wrong?
Thanks for any feedback!
Rita

First attempt:
> eqSystem2 <-paste(paste("form", 1:4, sep=""), as.formula(paste("EQ", 
> 1:4,sep="")),sep="=")
  eqSystem2

RESULT: [1] "form1=~"            "form2=Y1"           "form3=X1 + X2 + X4" 
"form4=~"
Second attempt:> eqSystem2 <-paste(paste("form", 1:4, sep=""), paste("EQ", 
1:4,sep=""),sep="=")
  eqSystem2 <-as.formula(eqSystem2)
  eqSystem2

RESULT:Y1 ~ X1 + X2 + X4
Third attempt:> eqSystem2 <-paste(paste("form", 1:4, sep=""),paste("EQ", 
1:4,sep=""), sep="=")
eqSystem2 <-as.list(eqSystem2)
eqSystem2 <-as.formula(eqSystem2)
eqSystem2

RESULT: Error in formula.default(object, env = baseenv()) : invalid formula
[[1]]
[1] "form1=EQ1"

[[2]]
[1] "form2=EQ2"

[[3]]
[1] "form3=EQ3"

[[4]]
[1] "form4=EQ4"
Fourth attempt:> eqSystem2 <-paste(paste("form", 1:4, sep=""),paste("EQ", 
1:4,sep=""), sep="=")
eqSystem2 <-as.formula(eqSystem2)
eqSystem2 <-as.list(eqSystem2)
eqSystem2
RESULT: [[1]]
`~`

[[2]]
Y1

[[3]]
X1 + X2 + X4



> Date: Wed, 22 Jun 2011 01:36:28 +0300
> From: d.kazakiew...@gmail.com
> To: ritacarre...@hotmail.com
> CC: r-help@r-project.org
> Subject: Re: [R] Setting up list of many equations for systemfit
> 
> Why don't try as.formula() function
> 
> On 22.06.2011 01:22, Rita Carreira wrote:
> > Dear List Members,I am trying to set up a large system of equations and I 
> > am trying to find a simple way to set up  the list command under the 
> > package system fit. Here is the example from system fit and what I am 
> > trying to do:
> > EQ1<- Y1 ~ X1 + X2 + X4EQ2<- Y2 ~ X2 + X3EQ3<- Y3 ~ X2 + X3 + X4EQ4<- Y4 ~ 
> > X1 + X3 + X4eqSystem<-list(form1 = EQ1, form2 = EQ2, form3 = EQ3, form4 = 
> > EQ4)
> > #atempt 1 to "automate" above:eqSystem1<-paste(paste("form", 1:4, sep=""), 
> > paste("EQ", 1:4,sep=""),sep="=")
> > #attempt 2  "automate" above:eqSystem2<-as.list(paste(paste("form", 1:4, 
> > sep=""), paste("EQ", 1:4,sep=""),sep="="))
> >
> > Here are the results:
> > The results that I want to get:>  eqSystem1$form1Y1 ~ X1 + X2 + X4
> > $form2Y2 ~ X2 + X3
> > $form3Y3 ~ X2 + X3 + X4
> > $form4Y4 ~ X1 + X3 + X4
> > The results of my attempts:attempt 1:>  eqSystem1 [1] "form1=EQ1" 
> > "form2=EQ2" "form3=EQ3" "form4=EQ4"
> > attempt 2:>  eqSystem2[[1]]
> > [1] "form1=EQ1"
> >
> > [[2]]
> > [1] "form2=EQ2"
> >
> > [[3]]
> > [1] "form3=EQ3"
> >
> > [[4]]
> > [1] "form4=EQ4"
> >
> > Does anyone have any ideas on how to correct my code?
> > Thanks,
> > Rita ===================================== "If you think education is 
> > expensive, try ignorance."--Derek Bok
> >                                     
> >     [[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.
> 
                                          
        [[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