[R] dataframe subset using levels as criteria

Ernesto Jardim ernesto at ipimar.pt
Wed Jan 30 17:06:16 CET 2002


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list