Data Visualization in R. MULTIPLE LlINE GRAPHS

ScREEN 2 exercise Answer - life_expec_sex <- life_expec >
filter(Race == “All Races” & Sex != “Both Sexes”). May we use life_expec_sex <- life_expec >
May we use filter(Race == “All Races” & (Sex ==Male | Sex==Female)). But it is not working.
If we want to filter only one variable from one column & 2 variables out of 5 variables in 2nd column , how to use filter.

Hi @sharathnandalike. The code provided is close, but Male and Female need to be in quotes, like this:

life_expec_sex <- life_expec %>%
  filter(Race == "All Races" & (Sex == "Male" | Sex== "Female"))

Another option is to link multiple filter conditions with the pipe operator %>% to make each step clear to the reader:

life_expec_sex <- life_expec %>%
  filter(Race == "All Races") %>%
  filter(Sex == "Male" | Sex== "Female")