[R] drop=F in [

About this list Date view Thread view Subject view Author view Attachment view

From: Agustin Lobo (alobo@ija.csic.es)
Date: Wed 25 Jul 2001 - 23:15:23 EST


Message-id: <Pine.OSF.3.96.1010725150958.19828G-100000@ija.csic.es>


Within a program, I subset a data matrix. Sometimes
it comes to remain one single row (indivual) out of the
subseting. The fact that the single row becomes
a vector with dim(x)=NULL instead of a matrix
with dim(x)=c(1,n), is inconvenient for further operations
in the program.

I thought that drop=F would solve this problem but...

lets a be:

> a
          [,1] [,2] [,3]
[1,] 0.3249816 1.184596 1.0408749
[2,] 1.4722996 1.408512 0.3768964
[3,] 1.2737683 1.811588 1.9108336
[4,] 1.8235127 1.260909 1.5995097

Then

> a[a[,1]<1,]
[1] 0.3249816 1.1845962 1.0408749

> dim(a[a[,1]<1,])
NUL

But,

> a[a[,1]<1,drop=F]
[1] 0.3249816 1.1845962 1.0408749
> dim(a[a[,1]<1,drop=F])
NULL

No way to get dim(a[a[,1]<1,]) equal to c(1,3) ?

Thanks

Agus

Dr. Agustin Lobo
Instituto de Ciencias de la Tierra (CSIC)
Lluis Sole Sabaris s/n
08028 Barcelona SPAIN
tel 34 93409 5410
fax 34 93411 0012
alobo@ija.csic.es

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Wed 10 Mar 2004 - 08:18:21 EST