Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.LNX.4.44.0304241841260.1577-100000@gannet.stats>
Date: 2003-04-24T17:44:18Z
From: Brian Ripley
Subject: matrix subset question
In-Reply-To: <OF6E561127.2B33AF51-ON85256D12.0059F861@mail.gm.com>

On Thu, 24 Apr 2003 tomas.larsson at gm.com wrote:

> Dear R-helpers,
> 
> If P is a matrix and I want to obtains one column from P I write:
> 
> x<-P[,k]
> 
> I always want to maintain the data as a matrix, even if the data is a
> single row, to do that I have to write:
> 
> x<-P[,k,drop=FALSE]

> Here is my question:
> Is there any way that I can change my default to be drop=FALSE so that I do
> not have to add this every single time?

No.

And you would not want to, for much of R is itself written in R and relies 
on the default behaviour of subsetting.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595