Skip to content
Prev 884 / 15274 Next

How to get values from dataframe's column conditional on other column

On Tue, Jun 13, 2006 at 12:35:36PM +0100, Yuri Volchik wrote:
You would do yourself a huge favour if you read the 'An Introduction to R'
manual distributed with R, or, for that matter, any of the other contributed  
introductory manuals on the R/CRAN site.

The answer, by the way, is 

    DF[ DF[,"Y"]==TRUE, "X" ]

ie you create a boolean condution for the rows (and == 'TRUE' could be
omitted if Y is boolean), and then select "X".  There are still issues that
may confuse you about data.frames collapsing to a single vector, please go
and read the manual. Really.

Dirk