I am working with some Code containing the expression %||%.
This is the context i encountered it:
# Example list for minimal example
df <- list(a=1,2,c=3)
# code
ind <- names(df) %||% seq_along(df)
But R cannot find the operator %||%. I guess a package is not installed but i do not know which one. I also cannot find it on google or stackoverflow.
Could someone explain what it does and which package it belongs to?
>Solution :
It’s from ggplot2 utilities.
"%||%" <- function(a, b) {
if (!is.null(a)) a else b
}
You can find in utilities.r