Re: [R] passing a string to expand.grid

From: Thomas Kaliwe <hamstersquats_at_web.de>
Date: Sat 13 May 2006 - 02:23:25 EST


Thank you

-----Ursprüngliche Nachricht-----
Von: ggrothendieck@gmail.com [mailto:ggrothendieck@gmail.com] Gesendet: Freitag, 12. Mai 2006 16:26
An: Thomas Kaliwe
Cc: r-help@stat.math.ethz.ch
Betreff: Re: [R] passing a string to expand.grid

Try this:

x <- "c(-1,1), c(-1,1)"
eval(parse(text = paste("expand.grid(", x, ")")))

On 5/12/06, Thomas Kaliwe <hamstersquats@web.de> wrote:
> Hi R-Users,
>
> I'm having a problem with strings.
>
> My string looks like this "c(-1,1), c(-1,1)" and I would like to pass
it
> to expand.grid so that expand.grid(c(-1,1),c(-1,1)) will be done.
>
> Cheers,
>
> Thomas
>
> ______________________________________________
> 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
>



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 Received on Sat May 13 02:47:52 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 13 May 2006 - 04:10:08 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.