[R] selecting by variable

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Aug 27 11:07:34 CEST 2003


hist(X[Y>=A & Y<=B])

`An Introduction to R' explains such things, as do (in more detail) the 
introductory texts (see the R FAQ).


On Wed, 27 Aug 2003, Eugene Salinas wrote:

> I'm a recent R convert so I haven't quite figured out
> the details yet...
> 
> How do I select one variable by another one? Ie if I
> want to draw the histogram of variable X only for
> those individuals that also have a value Y in a
> certain range?
> 
> In STATA I would give something like:
> 
> histogram X if ((Y>=A & Y<=B))
> 
> (The data is for individuals and each individual has a
> number of characteristics including X and Y).

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list