In both of these cases, the function does the same thing.
Here it is from rCharts:
#' Set a default value for an object
#'
#' This function sets the value of an object to a default value if it is not defined.
#' @params x object
#' @params y object
#' @keywords internal
#' @noRd
`%||%` <- function(x, y){
if (is.null(x)) y else x
}
Here it is from "ggplot2"--slightly different syntax but same operation:
ggplot2:::`%||%`
# function (a, b)
# {
# if (!is.null(a))
# a
# else b
# }
For finding the definitions of these functions, you can start by trying getAnywhere()
. Here's the result on my system:
getAnywhere("%||%")
# 3 differing objects matching ‘%||%’ were found
# in the following places
# namespace:ggplot2
# namespace:gtable
# namespace:plyr
# namespace:reshape2
# namespace:scales
# Use [] to view one of them
Edit: note that [] accepts numeric arguments, not the package names