[R] Don't collapse degenerate array indices

Duncan Murdoch murdoch.duncan at gmail.com
Thu Apr 19 15:25:25 CEST 2012


On 19/04/2012 9:14 AM, Sebastian Schubert wrote:
> Hi,
>
> I want to prohibit the automatic collapsing of degenerate array indices:
>
> >  str( array(1,dim=c(3,4,5,1,1)) )
>   num [1:3, 1:4, 1:5, 1, 1] 1 1 1 1 1 1 1 1 1 1 ...
> >  str( array(1,dim=c(3,4,5,1,1))[2:3,1:3,4:5,,] )
>   num [1:2, 1:3, 1:2] 1 1 1 1 1 1 1 1 1 1 ...
>
> The last command removed the degenerate indices. I don't want that. What
> can I do?

Use "drop=FALSE".  See ?"[".

Duncan Murdoch



More information about the R-help mailing list