0 votes
1 view
in R Programming by (6.5k points)

A categorical variable V1 in a data frame D1 can have values represented by the letters from A to Z. I want to create a subset D2, which excludes some values, say, B, N and T. Basically, I want a command which is the opposite of %in%

D2 = subset(D1, V1 %in% c('B','N',T'))

1 Answer

0 votes
by (25.3k points)

To perform the opposite operation of %in% operator, use the following :

D2 = subset(D1, !(V1 %in% c('B','N','T')))

OR

'%ni%' <- Negate('%in%')

D2 = subset(D1, V1 %ni% c('B','N',T'))

Related questions

0 votes
1 answer
asked Jul 19, 2019 in R Programming by Ajinkya757 (5.3k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...