On Feb 20, 2011, at 5:56 PM, Dmitry Berman 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)

Don't reference the column number on the LHS:

m <- 1:7
m <- cbind(m, 8:14)

> m
     m
[1,] 1  8
[2,] 2  9
[3,] 3 10
[4,] 4 11
[5,] 5 12
[6,] 6 13
[7,] 7 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.

David Winsemius, MD
West Hartford, CT

______________________________________________
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.

Reply via email to