[R] selecting by variable
th50 at leicester.ac.uk
Wed Aug 27 11:15:18 CEST 2003
R allows indexing with logical vectors, so your example would look
hist(X[(Y>=A) & (Y<=B)])
See the manual "An Introduction to R" for details.
> -----Original Message-----
> From: Eugene Salinas [mailto:eugenesalinas2003 at yahoo.com]
> Sent: 27 August 2003 09:49
> To: r-help at stat.math.ethz.ch
> Subject: [R] selecting by variable
> 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).
> thanks, eugene.
> R-help at stat.math.ethz.ch mailing list
Research Associate in Medical Statistics
University of Leicester
Department of Epidemiology and Public Health
22-28 Princess Road West
Tel +44 116 252-5410
Fax +44 116 252-5423
Division of Medicine for the Elderly
Department of Medicine
The Glenfield Hospital
Tel +44 116 256-3643
Fax +44 116 232-2976
More information about the R-help