## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(minex)

## -----------------------------------------------------------------------------
script <- c(
  "a <- 10",
  "b <- 20",
  "log('not a number')"
)

res <- minex(code = script, backend = "inprocess")
res

## -----------------------------------------------------------------------------
cat(as.character(res), "\n")

## -----------------------------------------------------------------------------
script <- c(
  "x <- c(1, 2, NA)",
  "m <- mean(x)",
  "if (is.na(m)) stop('mean is NA')"
)
minex(code = script, backend = "inprocess")

## -----------------------------------------------------------------------------
minex(code = script, match = "class", backend = "inprocess")

## -----------------------------------------------------------------------------
minex(
  code = c("one <- 1", "two <- 2", "three <- 3"),
  oracle = function(stmts) any(grepl("two", stmts)),
  backend = "inprocess"
)

## -----------------------------------------------------------------------------
df <- data.frame(id = 1:6, value = c(3, 8, 999, 2, 5, 7))
reduce_rows(df, function(d) any(d$value > 100))

## -----------------------------------------------------------------------------
ddmin(strsplit("the quick brown fox", " ")[[1]], function(s) "fox" %in% s)

