[R] Is there a way to specify drop=FALSE as the global default?

tlumley at u.washington.edu tlumley at u.washington.edu
Wed Nov 11 21:38:22 CET 2009


On Wed, 11 Nov 2009, Peng Yu wrote:

> On Mon, Oct 19, 2009 at 7:57 PM, Peng Yu <pengyu.ut at gmail.com> wrote:
>> tmp <- matrix(1:2)
>> tmp
>> tmp[,1,drop=FALSE]
>>
>>
>> See the above example. Is there a way to make 'drop=FALSE' as global
>> default, so that when I say 'tmp[,1]', R will treat it as
>> 'tmp[,1,drop=FALSE]'?
>
> Is there a way to set drop=FALSE globally?

No.

> I can't remember to put
> drop=FALSE to all the '[]'s. But this indeed causes some weird bugs
> for me to figure out.

It would probably cause a lot more weird bugs if the behavior of [ depended on a global option.

          -thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle




More information about the R-help mailing list