asPch {easylegend}R Documentation

Converts categorical values to symbols. Wrapper for setFactorGraphics.

Description

Converts categorical values to symbols. Wrapper for setFactorGraphics.

Usage

asPch(x, export = FALSE, ...)

Arguments

x

A vector of numerical, character, boolean or factor values, representing categories (non-continuous, with a limited number of unique values).

export

Single logical value. If TRUE, the result of setFactorGraphics will be saved into the output attribute fg.

...

Additional parameters passed to setFactorGraphics.

Value

Returns a list of symbols.

Examples

library( "easylegend" ) 


# Example: x numerical values, points =======================
x <- sample( x = round(rnorm(10),2), size = 20, replace = TRUE )

asPch( x ) 
##  [1] 8 5 8 4 8 8 2 6 2 4 2 1 3 7 5 6 8 8 1 3
asPch( x, export = TRUE ) 
##  [1] 8 5 8 4 8 8 2 6 2 4 2 1 3 7 5 6 8 8 1 3
## attr(,"factorGraphics")
## $legend
## function (x, y = NULL, legend = c("-0.95", "-0.48", "-0.09", 
## "0.29", "0.35", "0.42", "1.19", "1.28"), col = NULL, pch = 1:8, 
##     fill = NULL, ...) 
## {
##     arguments <- list(x = x, y = y, legend = legend)
##     if (!is.null(col)) {
##         arguments <- c(arguments, list(col = col))
##     }
##     if (!is.null(fill)) {
##         arguments <- c(arguments, list(fill = fill))
##     }
##     if (!is.null(pch)) {
##         arguments <- c(arguments, list(pch = pch))
##     }
##     arguments <- c(arguments, list(...))
##     do.call(what = get("legend", pos = "package:graphics"), args = arguments)
##     return(invisible(arguments))
## }
## <environment: 0x07d46784>
## 
## $pch
## function (x) 
## {
##     x <- data.frame(values = x, id = 1:length(x), stringsAsFactors = FALSE)
##     x <- merge(x = x, y = convert, by = "values", all.x = TRUE, 
##         sort = FALSE)
##     x <- x[order(x[, "id"]), ]
##     if (any(is.na(x[, "pch"]))) {
##         warning("Some values in 'x' are new. Symbol set to NA")
##     }
##     return(x[, "pch"])
## }
## <environment: 0x08270f20>
## 
## attr(,"class")
## [1] "factorGraphics"

[Package easylegend version 1.2.4 Index]