The R sources already contain an operator like that, though it is not
exported. tools:::`%notin%` is defined as
function (x, y)
is.na(match(x, y))
Several CRAN packages export a similar function, e.g. omnibus, mefa4,
data.table, hutils, etc. So I think if it was exported by R that's a
better name, but since it is easy to write yourself or import from some
other package, why bother?
Duncan Murdoch
On 2025-11-27 9:19 a.m., Marcelo Ventura Freire via R-devel
wrote:> Hello, dear R core developers
>
>
> I have a feature suggestion and, following the orientations in
>
https://contributor.r-project.org/rdevguide/chapters/submitting_feature_requests.html,
> I have searched in Bugzilla to the best of my capabilities for suggestions
> like the one I have in mind but found no results (however, I can be wrong).
>
> My idea is including this line
>
> `%!in%` <- function(x, table) match(x, table, nomatch = 0L) == 0L
>
> between lines 39 and 40 of the file "src/library/base/R/match.R".
>
> My objective is to create a "not in" operator that would allow us
to write
> code like
>> value %!in% valuelist
> instead of
>> ! value %in% valuelist
> which is in line with writing
>> value1 != value2
> instead of
>> ! value1 == value2
>
> I was not able to devise any reasonable way that such inclusion would break
> any already existing heritage code unless that operator would be defined
> otherwisely and it would improve (however marginally) the readability of
> future code by its intuitive interpretation and by stitching together two
> operators that currently stand apart each other.
>
> So, if this suggestion was not already proposed and if it is seen as
> useful, I would like to include it in the wishlist in Bugzilla.
>
> I would appreciate any feedback, be it critic or support, and I hope I have
> not crossed any communicational rule from the group.
>
> Many thanks! ?
>
>
>
> Marcelo Ventura Freire
> Escola de Artes, Ci?ncias e Humanidades
> Universidade de S?o Paulo
> Av. Arlindo Bettio, 1000,
> Sala Paulo Freire (Sala Coletiva 252), Pr?dio I1
> Ermelino Matarazzo, S?o Paulo, SP, Brasil
> CEP 03828-000
> Tel.: (11) 3091-8894
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel