R/can.operator.R

Defines functions can.operator can.operator.default can.operator.name can.operator.function can.operator.character

Documented in can.operator

#' can.operator
#' 
#' tests whether an object can be coerced to a operator, optionally an operator
#' of 'types'.
#' 
#' 
#' @param x object; to test
#' @param ... additional arguments 
#' 
#' \code{can.operator} test whether an object can be coerced to an operator.
#' Methods exist for name, function amd character classes
#' 
#' @return logical

#' @export
can.operator <- function(x, ... )
  UseMethod( 'can.operator', x ) 

#' @export
can.operator.default <- function(x,...) FALSE

#' @export
can.operator.name <- function(x,...) 
  deparse(x) %in% operators(...)

#' @export
can.operator.function <- function(x,...) {
  deparse( x ) %in% 
  lapply( operators(...), function(op) deparse( eval( as.symbol(op) ) ) ) 
}  

#' @export
can.operator.character <- function(x,...) 
   x %in% operators(...)

Try the operator.tools package in your browser

Any scripts or data that you put into this service are public.

operator.tools documentation built on May 1, 2019, 8 p.m.