On Sun, Feb 20, 2011 at 2:56 PM, Dmitry Berman <ravenb...@gmail.com> wrote: > On Sun, Feb 20, 2011 at 5:55 PM, Dmitry Berman <ravenb...@gmail.com> wrote: > >> Listers, >> >> I have a simple matrix: >> >> ---------------------------------- >> m <-c(1:7) >> m <- cbind(m) >> >> m >> [1,] 1 >> [2,] 2 >> [3,] 3 >> [4,] 4 >> [5,] 5 >> [6,] 6 >> [7,] 7 >> ----------------------------------- >> >> I want to add a second column using: >> >> >> > m[,2] <- cbind(m,8:14) > But I get the error: > Error in m[, 2] <- cbind(m, 8:14) : subscript out of bounds > > What am I doing wrong? > > Thanks > > [[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 > and provide commented, minimal, self-contained, reproducible code. >
How about: m1 <-c(1:7) M1<-cbind(m1) M1 m2 <-c(2:8) M2<-cbind(m2) M2 cbind(M1,M2) ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.