How to specify “does not contain” in dplyr filter

前端 未结 2 1926
予麋鹿
予麋鹿 2020-12-08 02:27

I am quite new to R.

Using the table called SE_CSVLinelist_clean, I want to extract the rows where the Variable called where_case_travelled_1

2条回答
  •  眼角桃花
    2020-12-08 02:49

    Try putting the search condition in a bracket, as shown below. This returns the result of the conditional query inside the bracket. Then test its result to determine if it is negative (i.e. it does not belong to any of the options in the vector), by setting it to FALSE.

    SE_CSVLinelist_filtered <- filter(SE_CSVLinelist_clean, 
    (where_case_travelled_1 %in% c('Outside Canada','Outside province/territory of residence but within Canada')) == FALSE)
    

提交回复
热议问题