Re: [R] Loss of dimensions in subsetting arrays

2012-10-13 Thread Markku Karhunen
Ok, apologies. On Oct 12, 2012, at 2:52 AM, Markku Karhunen wrote: Hi all, I've been wondering for a long time why R drops the dimensions of an array/matrix when you try to take a subset of one column. I mean this: dim(A) [1] 2 5 2 B=A[1,,] dim(B) 5 2 # so now dim(B)[3] doesn't work

Re: [R] Loss of dimensions in subsetting arrays

2012-10-12 Thread David Winsemius
On Oct 12, 2012, at 2:52 AM, Markku Karhunen wrote: > > Hi all, > > I've been wondering for a long time why R drops the dimensions of an > array/matrix when you try to take a subset of one column. I mean this: > > dim(A) > [1] 2 5 2 > B=A[1,,] > dim(B) > 5 2 # so now dim(B)[3] doesn't work >

Re: [R] Loss of dimensions in subsetting arrays

2012-10-12 Thread Berend Hasselman
On 12-10-2012, at 11:52, "Markku Karhunen" wrote: > > Hi all, > > I've been wondering for a long time why R drops the dimensions of an > array/matrix when you try to take a subset of one column. I mean this: > > dim(A) > [1] 2 5 2 > B=A[1,,] Use B <- A[1,,,drop=FALSE] Also read the help

Re: [R] Loss of dimensions in subsetting arrays

2012-10-12 Thread Marc Schwartz
On Oct 12, 2012, at 4:52 AM, Markku Karhunen wrote: > > Hi all, > > I've been wondering for a long time why R drops the dimensions of an > array/matrix when you try to take a subset of one column. I mean this: > > dim(A) > [1] 2 5 2 > B=A[1,,] > dim(B) > 5 2 # so now dim(B)[3] doesn't work >

[R] Loss of dimensions in subsetting arrays

2012-10-12 Thread Markku Karhunen
Hi all, I've been wondering for a long time why R drops the dimensions of an array/matrix when you try to take a subset of one column. I mean this: dim(A) [1] 2 5 2 B=A[1,,] dim(B) 5 2 # so now dim(B)[3] doesn't work C=B[2,] dim(C) NULL # so now nrow(C) doesn't work Typically, you can get r