Skip to content
Prev 298967 / 398506 Next

Removing rows if certain elements are found in character string

On Jul 2, 2012, at 6:48 PM, Claudia Penaloza wrote:

            
You seem to be missing test cases for the second set of conditions but  
this works for the first set (and might for the second):

 > dat[ grepl("[^0dD]", dat$ch) & ! grepl("^0+d|^0^D", dat$ch) , ]
                                                  ch    count
3  000000000T00000000000000000000000000000000000000 0.007368
4  000000000TD0000000000000000000000000000000000000 0.007368
5  000000000T00000000000000000000000000000000000000 0.002456
6  000000000Td0000000000000000000000000000000000000 0.002456
7  00000000T000000000000000000000000000000000000000 0.007368
8  00000000T0D0000000000000000000000000000000000000 0.007368
9  00000000T000000000000000000000000000000000000000 0.002456
10 00000000T0d0000000000000000000000000000000000000 0.002456