Search code examples
rstatisticsprobability

R: Select only Rows where value greater than a certain value and Mapped to another column where value is Yes or No


I have a dataframe

df:
   Age   Answer
   25      No
   51      No
   45      Yes
   49      Yes
   25      Yes
   60      Yes

i want to get the ages of those who are >= 40 and Answered Yes so

df:
   Age
   45
   49
   60

Solution

  • Turns out it was pretty easy.

    x = df[df$Answer == "Yes"]
    x = df[df$Age >= 40]
    x$Age