[R] How to filter a data frame?

2008-07-22 Thread rlearner309
I have a question about how to filter the data frame: Suppose my data frame has variables like gender, age,... How to get a subset of the data frame, with only female (or male) and/or age > 50...? What is the typical syntax? I tried several condition expressions, but none of them worked... Than

Re: [R] How to filter a data frame?

2008-07-22 Thread John Kane
?subset Is this what you want? subset(dataset, gender="M" | age < 50) --- On Tue, 7/22/08, rlearner309 <[EMAIL PROTECTED]> wrote: > From: rlearner309 <[EMAIL PROTECTED]> > Subject: [R] How to filter a data frame? > To: r-help@r-project.org > Received

Re: [R] How to filter a data frame?

2008-07-22 Thread Marc Schwartz
on 07/22/2008 08:47 AM rlearner309 wrote: I have a question about how to filter the data frame: Suppose my data frame has variables like gender, age,... How to get a subset of the data frame, with only female (or male) and/or age > 50...? What is the typical syntax? I tried several condition ex

Re: [R] How to filter a data frame?

2008-07-22 Thread Peter Dalgaard
John Kane wrote: ?subset Is this what you want? subset(dataset, gender="M" | age < 50) In case you didn't see it: Make that gender == "M" | age < 50 -- O__ Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K

Re: [R] How to filter a data frame?

2008-07-22 Thread milton ruser
May be this help you; Just intall.packages("sqldf", dependencies=T) require(sqldf) my_df<-data.frame(cbind(gender=sample(c("male","female"),50,replace=T), age=round(rnorm(50, mean=30, sd=5),0))) my_df_subset_male<-sqldf("select * from my_df where gender=='male'") my_df_subset_male my_df_subset_

Re: [R] How to filter a data frame?

2008-07-22 Thread John Kane
Ooops ! Thanks. --- On Tue, 7/22/08, Peter Dalgaard <[EMAIL PROTECTED]> wrote: > From: Peter Dalgaard <[EMAIL PROTECTED]> > Subject: Re: [R] How to filter a data frame? > To: [EMAIL PROTECTED] > Cc: r-help@r-project.org, "rlearner309" <[EMAIL PROTECTED]>

Re: [R] How to filter a data frame?

2008-07-22 Thread Roland Rau
Hi, rlearner309 wrote: I have a question about how to filter the data frame: Suppose my data frame has variables like gender, age,... How to get a subset of the data frame, with only female (or male) and/or age > 50...? What is the typical syntax? I tried several condition expressions, but non

Re: [R] How to filter a data frame?

2008-07-22 Thread rlearner309
Thank you all!! :-) rlearner309 wrote: > > I have a question about how to filter the data frame: > Suppose my data frame has variables like gender, age,... How to get a > subset of the data frame, with only female (or male) and/or age > 50...? > What is the typical syntax? I tried several