Skip to content
Prev 883 / 15274 Next

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

Hi to all members of this list,

I'm quite a novice to R and was wondering if there is a more elegant
way to solve a following problem:
Suppose we have a dataframe
  X     Y
.12   TRUE
-.24  TRUE
..     ...
.34   FALSE

i.e. two (or more columns) with data and we want to get vector of X
values conditional on Y values (say only X's when Y=TRUE).
Of course it is possible to do it by looping through the whole
dataframe, i was wondering if there is a a more elegant solution to
this in R?