Hi, I have a array like this data: 1 5 2 2342 3 33 and another data1: 1 6 2 5 3 7 when I do rbind(data,data1) I get not what I want they become 1 5 2 2342 3 33 101 6 102 5 103 7 but I want to make the index as increasing one by one. like 1 .. 2 .. 3 .. 4 .. 5 .. 6 .. So what command I should use thank you. [[alternative HTML version deleted]]
You need to provide a reproducible example. At least provide an 'str' of your data and preferably the output of 'dput'. I am not sure what you data looks like. works fine for me when using matrices:> data[,1] [1,] 5 [2,] 2342 [3,] 33> data1[,1] [1,] 6 [2,] 5 [3,] 7> rbind(data,data1)[,1] [1,] 5 [2,] 2342 [3,] 33 [4,] 6 [5,] 5 [6,] 7>On Sun, Jun 21, 2009 at 8:31 PM, Xiaogang Yang <gavinxyang@gmail.com> wrote:> Hi, > I have a array like this > data: > 1 5 > 2 2342 > 3 33 > and another > data1: > 1 6 > 2 5 > 3 7 > when I do rbind(data,data1) > I get not what I want > they become > 1 5 > 2 2342 > 3 33 > 101 6 > 102 5 > 103 7 > > > > > but I want to make the index as increasing one by one. > like > 1 .. > 2 .. > 3 .. > 4 .. > 5 .. > 6 .. > > So what command I should use > > thank you. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]]
I'm guessing that your 'data' and 'data1' are just vectors so your 'rbind' command returns a 2 by 3 matrix. Jim showed you already that: rbind(as.matrix(data), as.matrix(data1)) will probably get you what you are looking for. However, I'm suspicious that just: c(data, data1) will serve you just as well. What are you planning on doing with a one-column matrix? Patrick Burns patrick at burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of "The R Inferno" and "A Guide for the Unwilling S User") Xiaogang Yang wrote:> Hi, > I have a array like this > data: > 1 5 > 2 2342 > 3 33 > and another > data1: > 1 6 > 2 5 > 3 7 > when I do rbind(data,data1) > I get not what I want > they become > 1 5 > 2 2342 > 3 33 > 101 6 > 102 5 > 103 7 > > > > > but I want to make the index as increasing one by one. > like > 1 .. > 2 .. > 3 .. > 4 .. > 5 .. > 6 .. > > So what command I should use > > thank you. > > [[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. >