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 ?Use %in% and not ==. == matches cyclically along the shorter vector, and I presume you want all cases matching any of the levels. -- 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._