[R] how to select cases based on value of one or more variables

Don MacQueen macq at llnl.gov
Sun Nov 30 21:49:45 CET 2008


It is.

For example, if you have a variable stored as a vector named "x", and 
another variable stored as aa vector named "y", you can select cases 
of y where x is greater than 3 by using

   y[x>3]

However, you're going to have to provide more information in order to 
get a better answer than that (see the posting guide, link included 
with every post to r-help). In particular, I'm guessing that the 
answer you really want looks somewhat different than my example -- 
but this depends on the exact structure of what read.spss() produces.

I'd also suggest reading some of the documentation available from the 
R website (CRAN), notably, "An Introduction to R".

-Don

At 9:36 PM +0100 11/30/08, Simone Gabbriellini wrote:
>dear list,
>
>I have read a spss file with read.spss()
>
>now I have a list with all my variable stored as vectors.
>
>is it possible to selec cases based on the value of one or more variables?
>
>thank you,
>Simone
>
>______________________________________________
>R-help at r-project.org mailing list
>https:// stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http:// www. R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.


-- 
---------------------------------
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
macq at llnl.gov



More information about the R-help mailing list