Learn R Programming

jwutil (version 1.2.3)

opt_binary_brute: selects columns from a data frame using an optimization function

Description

The optimization function is called with the data frame x and the names of each combination of the names of x's columns. An example of real-world usage is to automate selection of columns according to the optimization function.

Usage

opt_binary_brute(x, fun = opt_binary_fun, verbose = FALSE)

Arguments

x

data frame

fun

function which takes parameters x = data.frame, n = columns

verbose

single logical value, if TRUE then produce verbose messages

Examples

Run this code
# NOT RUN {
j <- data.frame(a = 1:5, b = 6:2, c = c(0, 2, 4, 6, 8))
opt_binary_brute(j)
j[1, 1] <- NA
j[1:4, 2] <- NA
my_opt_fun <- function(x, n) sum(!unlist(lapply(x, is.na)))
opt_binary_brute(j, fun = my_opt_fun)
# }

Run the code above in your browser using DataLab