Interpolate values into an expression.

This is useful if you want to build an expression up from a mixture of constants and variables.

interp(`_obj`, ..., .values)

An object to modify: can be a call, name, formula, lazy, or a string.

..., .values

Either individual name-value pairs, or a list (or environment) of values.

  • interp
# Interp works with formulas, lazy objects, quoted calls and strings
interp(~ x + y, x = 10)
interp(lazy(x + y), x = 10)
interp(quote(x + y), x = 10)
interp("x + y", x = 10)

# Use if you have a character string that gives a
# variable name
interp(~ mean(var), var ="mpg"))
# or supply the quoted name directly
interp(~ mean(var), var = quote(mpg))

# Or a function!
interp(~ f(a, b), f ="+"))
# Remember every action in R is a function call:

# If you've built up a list of values through some other
# mechanism, use .values
interp(~ x + y, .values = list(x = 10))

# You can also interpolate variables defined in the current
# environment, but this is a little risky.
y <- 10
interp(~ x + y, .values = environment())
# }
Documentation reproduced from package lazyeval, version 0.2.2, License: GPL-3

Community examples

Looks like there are no examples yet.