Hi all, I have two variables x and y. X has five observation and y has three. I want combine each element of x to each element of y values to produce 15 observation. Below is my sample data and desired output data x Y 1 A 2 B 3 C 4 5 Output 1 A 1 B 1 C 2 A 2 B 2 C 3 A 3 B 3 C 4 A 4 B 4 C 5 A 5 B 5 C Thank you in advance
Is this homework? We don't do homework here. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Wed, Apr 12, 2017 at 6:28 PM, Val <valkremk at gmail.com> wrote:> Hi all, > I have two variables x and y. X has five observation and y has three. > I want combine each element of x to each element of y values to > produce 15 observation. Below is my sample data and desired output > > data > x Y > 1 A > 2 B > 3 C > 4 > 5 > > Output > 1 A > 1 B > 1 C > 2 A > 2 B > 2 C > 3 A > 3 B > 3 C > 4 A > 4 B > 4 C > 5 A > 5 B > 5 C > > Thank you in advance > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.
?expand.grid -- Sent from my phone. Please excuse my brevity. On April 12, 2017 6:28:24 PM PDT, Val <valkremk at gmail.com> wrote:>Hi all, >I have two variables x and y. X has five observation and y has three. >I want combine each element of x to each element of y values to >produce 15 observation. Below is my sample data and desired output > >data >x Y >1 A >2 B >3 C >4 >5 > >Output >1 A >1 B >1 C >2 A >2 B >2 C >3 A >3 B >3 C >4 A >4 B >4 C >5 A >5 B >5 C > >Thank you in advance > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >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.