I'd like to subset a dataframe to include only rows that have a specific words ("ab" in this example) in many columns. Here's my example:
>df
ID RESULT1 RESULT2 RESULT3 RESULT4 ... RESULT30
1 001 abc abcd abcdef cdef ... efs
2 002 cd efg hij kl ... fzh
3 003 zabc efg jgh ldc ... bcs
4 004 efx cde lfs ab ... cd
5 005 ftx txs sgs lfc ... edf
6 006 lsd mde ald ldf ... klj
7 007 kjl ell oip lab ... jkl
Expected output would be something like this (Rows that have "ab" in any columns.
>df.sub
ID RESULT1 RESULT2 RESULT3 RESULT4 ... RESULT30
1 001 abc abcd abcdef cdef ... efs
3 003 zabc efg jgh ldc ... bcs
4 004 efx cde lfs ab ... cd
7 007 kjl ell oip lab ... jkl
Can somebody give some solutions? I am new to R. Thanks in advance.