我对R非常陌生。
使用名为SE_CSVLinelist_clean
的表格,我想提取变量名为where_case_travelled_1
且不包含字符串"Outside Canada"
或"Outside province/territory of residence but within Canada"
的行。然后创建一个名为SE_CSVLinelist_filtered
的新表格。
SE_CSVLinelist_filtered <- filter(SE_CSVLinelist_clean,
where_case_travelled_1 %in% -c('Outside Canada','Outside province/territory of residence but within Canada'))
上面的代码在我只使用"c"而不是"-c"时可行。那么,当我真正想要排除包含国外或省份之外内容的行时,我该如何指定上述内容?答案: 上面的代码在只使用"c"而不是"-c"时可行。那么,当我真正想要排除包含国外或省份之外内容的行时,我该如何指定呢?
\
%notin%` = function(x,y) !(x %in% y)。然后你可以使用
x %notin% y代替
!(x %in% y)`。 - eipi10