[R] selecting by variable

Ko-Kang Kevin Wang kwan022 at stat.auckland.ac.nz
Wed Aug 27 11:05:58 CEST 2003


On Wed, 27 Aug 2003, Eugene Salinas wrote:

> I'm a recent R convert so I haven't quite figured out
> the details yet...

Usually it is good to read the manuals when you use a unfamiliar 
software...

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

e.g.
  x = rnorm(100)
  y = 1:100
  x[y = 20:50]
will give you the value of x when y is between 20 and 50.  To do a 
histogram, type:
  ?hist

-- 
Cheers,

Kevin

------------------------------------------------------------------------------
"On two occasions, I have been asked [by members of Parliament],
'Pray, Mr. Babbage, if you put into the machine wrong figures, will
the right answers come out?' I am not able to rightly apprehend the
kind of confusion of ideas that could provoke such a question."

-- Charles Babbage (1791-1871) 
---- From Computer Stupidities: http://rinkworks.com/stupid/

--
Ko-Kang Kevin Wang
Master of Science (MSc) Student
SLC Tutor and Lab Demonstrator
Department of Statistics
University of Auckland
New Zealand
Homepage: http://www.stat.auckland.ac.nz/~kwan022
Ph: 373-7599
    x88475 (City)
    x88480 (Tamaki)




More information about the R-help mailing list