Learn R Programming

playwith (version 0.8-56)

callArg: Work with plot call arguments

Description

Part of the playwith Application Programming Interface.

Usage

callArg(playState, arg, expr, data = NULL)
callArg(playState, arg, expr) <- value

mainCall(playState)
mainCall(playState) <- value

Arguments

playState
a playState object representing the plot, window and device.
arg
the argument name or number in the plot call (playState$call). Argument numbers start from 1 (so 0 refers to the function name). This can also be a language object (e.g. quote(scales$log)).
expr
an alternative way to specify arg: as a raw expression. This is evaluated in the calling environment, so can refer to local variables (e.g. data[[myname]]).
data
a list or environment in which to evaluate the argument. Typically this will be the "data" argument to lattice or qplot functions.
value
the value to assign.

Value

  • returns the value of the specified argument, as if using the $ or [[ extractor functions, but evaluated in a local environment (playState$env).

Details

These functions get and set argument values in the playState plot call. As convenience functions for setting arguments in playState$call, the callArg function helps by:
  • referring to the main call that accepts plot arguments, which is not necessarily the top-level call.
  • automatically evaluating variables that have been stored in a local environment (playState$env).
  • converting lists to language objects so that the call can be deparsed elegantly.
  • enforcing exact matching of argument namesexact=TRUE(see[[).

See Also

playwith.API

Examples

Run this code
if (interactive()) {

library(lattice)
playwith(xyplot(1:10 ~ 1:10))
playState <- playDevCur()

callArg(playState, "pch")  ## NULL
callArg(playState, "pch") <- "$"
callArg(playState, "pch")  ## "$"
playReplot(playState)

## referring to local variables
tmp <- "x"
callArg(playState, expr = scales[[tmp]]$cex) <- 2
playReplot(playState)

## quoted expressions can also be used
callArg(playState, quote(scales$x$cex))

}

Run the code above in your browser using DataLab