How to Apply the match.fun() Function in R (Example Code)

This tutorial illustrates how to apply the match.fun command in R programming.

Example: Return Function Specified by Name Using match.fun() Command

match.fun(var)                     # Apply match.fun function
# function (x, y = NULL, na.rm = FALSE, use) 
# {
#     if (missing(use)) 
#         use <- if (na.rm) 
#             "na.or.complete"
#         else "everything"
#     na.method <- pmatch(use, c("all.obs", "complete.obs", "pairwise.complete.obs", 
#         "everything", "na.or.complete"))
#     if (is.na(na.method)) 
#         stop("invalid 'use' argument")
#     if (is.data.frame(x)) 
#         x <- as.matrix(x)
#     else stopifnot(is.atomic(x))
#     if (is.data.frame(y)) 
#         y <- as.matrix(y)
#     else stopifnot(is.atomic(y))
#     .Call(C_cov, x, y, na.method, FALSE)
# }
# <bytecode: 0x556b149f12c0>
# <environment: namespace:stats>

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top