Gundala Viswanath
2013-Jun-10 05:25 UTC
[R] How to expand.grid with string elements (the half!)
I have the following result of expand grid:> d <- expand.grid(c("x","y","z"),c("x","y","z"))What I want is to create a combination of strings but only the half of the all combinations: Var1 Var2 1 x x 2 y x 3 y y 4 z y 5 x z 6 z z What's the way to do it? G.V. [[alternative HTML version deleted]]
Your question makes no sense at all. The grid expansion has 9 rows. In case you hadn't noticed, 9 is an odd number (i.e. not divisible by 2). There are no "halves". Do not expect the list to read your mind. Instead, ask a meaningful question. cheers, Rolf Turner On 10/06/13 17:25, Gundala Viswanath wrote:> I have the following result of expand grid: > >> d <- expand.grid(c("x","y","z"),c("x","y","z")) > What I want is to create a combination of strings > but only the half of the all combinations: > > Var1 Var2 > 1 x x > 2 y x > 3 y y > 4 z y > 5 x z > 6 z z > > > What's the way to do it?
MacQueen, Don
2013-Jun-10 15:16 UTC
[R] How to expand.grid with string elements (the half!)
If you can explain why those particular six combinations out of the complete set of nine, then perhaps someone can tell you how. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 6/9/13 10:25 PM, "Gundala Viswanath" <gundalav at gmail.com> wrote:>I have the following result of expand grid: > >> d <- expand.grid(c("x","y","z"),c("x","y","z")) > >What I want is to create a combination of strings >but only the half of the all combinations: > > Var1 Var2 >1 x x >2 y x >3 y y >4 z y >5 x z >6 z z > > >What's the way to do it? > >G.V. > > [[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.