[R] selecting data from a data.frame?

Paul E Johnson pauljohn at ku.edu
Fri Jan 4 23:03:34 CET 2002


I have this trivia sheet called Rtips and I collect answers to practical 
questions like that one:

http://lark.cc.ukans.edu/~pauljohn/R/statsRus.html#2.4

Have a look!

Every time I see a question like I would ask, I stick it in that 
notebook because I can't remember anything otherwise.

Michael A. Miller wrote:

> I know how to plot a subset of a data.frame by doing something
> like 
> 
>  > plot( mydata$x[y>2] )
> 
> Is there a way to do something similar for an entire data.frame?
> For example, I can do this something like
> 
>  > lm( x[y>2] ~ type[y>2], data=mydata )
> 
> but I'm a lazy typist, so I'd like to be able to do something
> like 
> 
>  > lm( x ~ type, data=mydata[y>2] )
> 
> Is there a way to select rows from a data frame like that?
> 
> Mike
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 



-- 
Paul E. Johnson                       email: pauljohn at ukans.edu
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700

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