Hi, I have a problem with the R syntax. It's perhaps pretty simple, but I don't understand it ... I can extract a column from a data.frame with the following code for example ... b$row1[b$row1 == "male"] so I see all male-entries. But I cannot extract all lines of a data.frame depending on this criterium; only.male <- b[b$row1 == "male"] With that, I get an "undefined columns selected" message. So how can I extract lines of a data.frame depending on a level variable?
You are missing a comma. You are addressing the dataframe as if it were a matrix and you want to extract all the rows that match: only.male <- b[b$row1 == "male",] On Fri, Jan 16, 2009 at 9:57 PM, J?rg Gro? <joerg at licht-malerei.de> wrote:> Hi, > > I have a problem with the R syntax. > It's perhaps pretty simple, but I don't understand it ... > > > I can extract a column from a data.frame with the following code for example > ... > > > b$row1[b$row1 == "male"] > > > so I see all male-entries. > > > But I cannot extract all lines of a data.frame depending on this criterium; > > only.male <- b[b$row1 == "male"] > > > With that, I get an "undefined columns selected" message. > > > So how can I extract lines of a data.frame depending on a level variable? > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
On 17-Jan-09 02:57:13, J?rg Gro? wrote:> Hi, > I have a problem with the R syntax. > It's perhaps pretty simple, but I don't understand it ... > > I can extract a column from a data.frame with the following code > for example ... > > b$row1[b$row1 == "male"] > > so I see all male-entries. > > But I cannot extract all lines of a data.frame depending on this > criterium; > > only.male <- b[b$row1 == "male"] > > With that, I get an "undefined columns selected" message. > > So how can I extract lines of a data.frame depending on a level > variable?only.male <- b[b$row1 == "male",] should work. Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 17-Jan-09 Time: 09:48:43 ------------------------------ XFMail ------------------------------