[R] expand.grid on contents of a list
arun
smartpink111 at yahoo.com
Fri Feb 1 16:07:30 CET 2013
Hi,
expand.grid(X)
# Var1 Var2 Var3
#1 1 1 1
#2 2 1 1
#3 1 2 1
#4 2 2 1
#5 1 1 2
#6 2 1 2
#7 1 2 2
#8 2 2 2 expand.grid(1:2,1:2,1:2)
# Var1 Var2 Var3
#1 1 1 1
#2 2 1 1
#3 1 2 1
#4 2 2 1
#5 1 1 2
#6 2 1 2
# 1 2 2
#8 2 2 2
A.K.
----- Original Message -----
From: Dimitri Liakhovitski <dimitri.liakhovitski at gmail.com>
To: r-help <r-help at r-project.org>
Cc:
Sent: Friday, February 1, 2013 8:48 AM
Subject: [R] expand.grid on contents of a list
Hello!
I have a list of variable length. One example is:
X=vector("list",3)
X[[1]]=1:2
X[[2]]=1:2
X[[3]]=1:2
How could I run expand.grid on the elements of X so that the results would
be the same as expand.grid(1:2,1:2,1:2)?
Thank you!
Dimitri
--
Dimitri Liakhovitski
gfk.com <http://marketfusionanalytics.com/>
[[alternative HTML version deleted]]
______________________________________________
R-help at 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.
More information about the R-help
mailing list