[R] How to write string dynamicly?

Gabor Grothendieck ggrothendieck at gmail.com
Wed Dec 27 19:56:26 CET 2006


Try:

lda(iris[-5], iris[,5])

On 12/26/06, Feng Qiu <fqiu at gatech.edu> 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 at 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.
>



More information about the R-help mailing list