Skip to content
Back to formatted view

Raw Message

Message-ID: <x24rtbjreh.fsf@blueberry.kubism.ku.dk>
Date: 2001-06-20T11:56:54Z
From: Peter Dalgaard
Subject: select cases from a data.frame or matrix
In-Reply-To: "Till Baumgaertel"'s message of "Wed, 20 Jun 2001 13:38:09 +0200"

"Till Baumgaertel" <till.baumgaertel at epost.de> writes:

> hi all,
> 
> is there a better solution to select rows from a data.frame than by iterating 
> through the whole set and evaluating every case one by one? 
> 
> is there maybe something like:
> d <- data.frame(...)
> maleOver40 <- select.data.frame( d, "( sex=m or sex=M) and age > 40)")
> 
> of course, i could use direct database-requests, but this would require my data 
> to be stored in a database...
> 
> thank you,
> till

subset(d, sex %in% c("m","M") & age > 40)


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._