0

on an old script, I had a line of code:

harris_residential_hmgpmatch <- subset(harris_residential_hmgpmatch, ID %!in% selecting_good$ID) #357

I need to rerun this script now, but the %!in% is no longer working:

Error in ID %!in% selecting_good$ID : could not find function "%!in%"

I have updated R since I initially wrote and ran this script - could that be the culprit, or am I missing something simple?

tchoup
  • 971
  • 4
  • 11
  • The "not in" operator is not included in base R. Many packages include a version of it though. Apparently in at least one of them it's called `%!in%`: https://stackoverflow.com/a/64139714/2854608 . Or if you do not want to load the package just use `!(ID %in% selecting_good$ID)` – qdread Jan 06 '22 at 00:55

2 Answers2

1

Maybe you can customize your function like this

`%!in%` <- Negate(`%in%`) 
lovalery
  • 4,524
  • 3
  • 14
  • 28
0

Try adding the ! operator to the entire argument:

harris_residential_hmgpmatch <- subset(harris_residential_hmgpmatch, !(ID %!in% selecting_good$ID))
jpsmith
  • 11,023
  • 5
  • 15
  • 36