Re: [R] Assignment working differently inside ifelse()

2011-08-16 Thread Stuart Luppescu
On Tue, 2011-08-16 at 12:10 -0500, Stuart Luppescu wrote: > but when I use the ifelse() as above, I get this: >[,1] [,2] [,3] [,4] > [1,] 0.0417 0.0417 0.0417 0.0417 > [2,] 0. 0. 0. 0. Oh, I see. ifelse() returns a value

Re: [R] Assignment working differently inside ifelse()

2011-08-16 Thread David Winsemius
On Aug 16, 2011, at 1:10 PM, Stuart Luppescu wrote: Hello all, I need to extract rows and columns from a data frame and put them in a matrix. In some cases, there are no rows in the data frame meeting the selection criteria. For those rows I want to put a row of 0's in the matrix. Here's my c

[R] Assignment working differently inside ifelse()

2011-08-16 Thread Stuart Luppescu
Hello all, I need to extract rows and columns from a data frame and put them in a matrix. In some cases, there are no rows in the data frame meeting the selection criteria. For those rows I want to put a row of 0's in the matrix. Here's my clumsy code: tab1.m1 <- matrix(0, nrow=2, ncol=4) tab1.m1