[R] drop=F in [

Agustin Lobo alobo at ija.csic.es
Wed Jul 25 15:15:23 CEST 2001


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 at 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 at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list