[R] subscripting a one column matrix drops dimension

Rolf Turner r.turner at auckland.ac.nz
Tue Oct 21 21:39:23 CEST 2008


On 22/10/2008, at 2:24 AM, Pedroso MOACIR wrote:

> Hi all,
>
> Why subscripting a one column matrix drops one dimension?
>
>> x<- matrix(rnorm(100), ncol=1)
>
>> str(x)
>  num [1:100, 1] -0.413 -0.845 -1.625 -1.393  0.507 ...
>
>> str(x[20:30,])
>  num [1:11] -0.315 -0.693 -0.771  0.448  0.204 ...
>
>> str(x[20:30])
>  num [1:11] -0.315 -0.693 -0.771  0.448  0.204 ...

	Try x[20:30,1,drop=FALSE]

		cheers,

			Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}



More information about the R-help mailing list