Add new column if range of columns contains string in R -
i have dataframe below. add 2 columns: containsanz: indicates if of columns f0 f3 contain 'australia' or 'new zealand' ignoring na values allanz: indicates if non na columns contain 'australia' or 'new zealand' starting dataframe be: dfcontainsanz col.a col.b col.c f0 f1 f2 f3 1 data 0 xxx australia singapore <na> <na> 2 data 1 yyy united states united states united states <na> 3 data 0 zzz australia australia australia australia 4 data 0 ooo hong kong london australia <na> 5 data 1 xxx new zealand <na> <na> <na> the end result should this: df col.a col.b col.c f0 f1 f2 f3 containsanz allanz 1 data 0 xxx australia singapore <na> <na> australia unde