Doubt - Assign values to variable with a filter

Hi mates!

I have I have two columns; the first one is the Age and the second one is the sex (male or female).

I need to assign the value of the attribute age with the filter "Male" to a variable (AgeMale).

I've tried this: AgeMale <- datosAdult %>% filter(datosAdult$sex == "Male") %>% select(datosAdult$age)

But I've this error : could not find function %>%

¿Could anyone help me with this?

You probably do not have library(dplyr). Try below code:

library(dplyr)
AgeMale <- datosAdult %>% filter(sex == "Male") %>% select(age)

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.