Re: [R] dimensions dropped on assignment

2012-01-31 Thread Ernest Adrogué
Hi, Thanks for your comments, the issue remains unsolved though. I insist the dropping of dimensions only appears to occur in assignments > out <- array(0, 5, list(1:5)) > out 1 2 3 4 5 0 0 0 0 0 > dim(out) [1] 5 > dim(out[as.character(2:3)]) [1] 2 There is no dropping here, but then > out[as

Re: [R] dimensions dropped on assignment

2012-01-31 Thread Richard M. Heiberger
> tmp <- matrix(1:12, 3, 4, dimnames=list(letters[1:3], LETTERS[1:4])) > tmp A B C D a 1 4 7 10 b 2 5 8 11 c 3 6 9 12 > tmp["a",, drop=FALSE] A B C D a 1 4 7 10 > tmp[,"A",drop=FALSE] A a 1 b 2 c 3 > you need the correct number of commas. For your example > dim(out[1, drop=FALSE]) [1] 1

[R] dimensions dropped on assignment

2012-01-31 Thread Ernest Adrogué
Hi there, This is a problem I've run into and do not know how to avoid. It happens when I make an assignment using the dimension names as the subscript of the array. The end result is a dimenensionless array (i.e. a vector) which I don't want. See: > out <- array(0, 5, list(1:5)) > dim(out) [1] 5