apply.method: Apply a Positioning Method

apply.methodR Documentation

Apply a Positioning Method

Description

Run a Positioning Method list on a given data set. This function contains all the logic for parsing a Positioning Method and sequentially applying its elements to the input data to obtain the label positions.

Usage

apply.method(method, 
    d, columns.to.check = c("x", 
        "y", "groups", 
        "label"), ..., 
    debug = FALSE)

Arguments

method

Direct labeling Positioning Method. Starting from the data frame of points to plot for the panel, the elements of the Positioning Method list are applied in sequence, and then each row of the resulting data frame is used to draw a direct label. The elements of a Positioning Method list can be

  • a Positioning Function is any function(d,...) which takes a data.frame d with columns x,y,groups and returns another data.frame representing the positions of the desired direct labels. For a description of all the columns that are interpreted for drawing direct labels, see drawDetails.dlgrob. For example, maxvar.points is a Positioning Function that returns a data.frame with columns x,y,groups,hjust,vjust.

  • a character vector of length 1 is treated as the name of an R object. For example, specifying "maxvar.points" means to look up the variable called maxvar.points and use that. Using the name of a Positioning Function is preferable to specifying the Positioning Function itself, since then the name is visible in the Positioning Method list, which is more interpretable when debugging.

  • a named list element is used to add or update variables in the data.frame of direct labels to plot. For example list("first.points",cex=1.5) means take only the first points of every group and then set the cex column to 1.5.

  • an element of a Positioning Method list can be another Positioning Method list, in which case the elements of the inner list are applied.

d

Data frame to which we apply the Positioning Method. The x and y columns should be in centimeters (cm), so that Positioning Methods can easily calculate the L2/Euclidean/visual distance between pairs of points.

columns.to.check

After applying each Positioning Method list element, we check for the presence of these columns, and if not found we stop with an error.

...

Named arguments, passed to Positioning Functions.

debug

If TRUE, print each Positioning Method list elmenent and the direct label data.frame that results from its evaluation.

Value

The final data frame returned after applying all of the items in the Positioning Method list, with x and y in units of cm.

Author(s)

Toby Dylan Hocking


tdhock/directlabels documentation built on April 21, 2024, 11:32 a.m.