expand.grid using a repeated vector as a parameter

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

expand.grid using a repeated vector as a parameter

ppaarrkk
Hello.


I'm trying to do this (not necessarily 0:1)  :


expand.grid ( 0:1, 0:1, 0:1, 0:1, 0:1)

etc..etc.


but I want to have control over how many 0:1 are included.


Any ideas please ?

Thankyou.


Simon Parker
Imperial College



       
---------------------------------

A Smarter Email.
        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: expand.grid using a repeated vector as a parameter

Prof Brian Ripley
?do.call

On Fri, 2 May 2008, Simon Parker wrote:

> Hello.
>
>
> I'm trying to do this (not necessarily 0:1)  :
>
>
> expand.grid ( 0:1, 0:1, 0:1, 0:1, 0:1)
>
> etc..etc.
>
>
> but I want to have control over how many 0:1 are included.
>
>
> Any ideas please ?
>
> Thankyou.
>
>
> Simon Parker
> Imperial College
>
>
>
>
> ---------------------------------
>
> A Smarter Email.
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: expand.grid using a repeated vector as a parameter

Greg Snow-2
In reply to this post by ppaarrkk
Try:

> tmp <- rep( list( 0:1 ), 5 )
> out <- do.call(expand.grid, tmp)

Then change the 5 to whatever you want.

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[hidden email]
(801) 408-8111
 
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Simon Parker
> Sent: Friday, May 02, 2008 11:50 AM
> To: [hidden email]
> Subject: [R] expand.grid using a repeated vector as a parameter
>
> Hello.
>
>
> I'm trying to do this (not necessarily 0:1)  :
>
>
> expand.grid ( 0:1, 0:1, 0:1, 0:1, 0:1)
>
> etc..etc.
>
>
> but I want to have control over how many 0:1 are included.
>
>
> Any ideas please ?
>
> Thankyou.
>
>
> Simon Parker
> Imperial College
>
>
>
>        
> ---------------------------------
>
> A Smarter Email.
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.