[R] matrix subset question
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Apr 24 19:44:18 CEST 2003
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
More information about the R-help
mailing list