[R] dataframe subset using levels as criteria
Ben Bolker
ben at zoo.ufl.edu
Wed Jan 30 16:13:15 CET 2002
Perhaps you mean
frota[frota$matricula %in% levels(logbooks.eda$matricula),]
?
On 30 Jan 2002, Ernesto Jardim wrote:
> Hi
>
> I want to select a subset of a dataframe (frota) using the levels of a
> factor (matricula) in another dataframe (logbooks.eda).
>
> The command and output are bellow and it's not working ...
>
> > frota[frota$matricula==levels(logbooks.eda$matricula),]
> matricula compff tab potmaq
> 1 A-1420-C NA NA NA
> 2 A-1676-C NA 12070 36800
> 3 A-1954-C 3214 17565 44100
> 4 A-1961-C 3197 17992 46300
> 5 A-2011-C 3198 17184 46300
> Warning messages:
> 1: longer object length
> is not a multiple of shorter object length in: is.na(e1) | is.na(e2)
> 2: longer object length
> is not a multiple of shorter object length in:
> "==.default"(frota$matricula, levels(logbooks.eda$matricula))
>
> Can someone help me with this ?
>
> EJ
>
> ps: I'm using R-1.4.0-patched and SuSE 7.1
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
318 Carr Hall bolker at zoo.ufl.edu
Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker
Box 118525 (ph) 352-392-5697
Gainesville, FL 32611-8525 (fax) 352-392-3704
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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