Generally, you can create formula from string:

 lda(formula(paste(names(iris)[5],"~.")),iris)

On 12/28/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> Try:
>
> lda(iris[-5], iris[,5])
>
> On 12/26/06, Feng Qiu <[EMAIL PROTECTED]> wrote:
> > Hi everyone:
> >         I'm trying to compose a string dynamicly for the parameter input
> of
> > some function. For example:
> > In package MASS, function lda() require to input the name of predictor
> > variable. Let's say the 16th column is the predictor variable. Then we
> call
> > the function like this: lda(V16~., data=mydata). I don't want to hard-code
> > the call, instead, I would like to use a dynamic expression for this
> > parameter so that I can use my program on different set of data.
> >        I guess there,- are some function that can do this, but I didn't
> find
> > it in "Introduction to R" so far, could someone please tell me this kind
> of
> > function? Thank you!
> >
> > Best,
> >
> > Feng
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch 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.
> >
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>

______________________________________________
R-help@stat.math.ethz.ch 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