forked from tidyverse/ggplot2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaes_string.Rd
45 lines (41 loc) · 1.29 KB
/
aes_string.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/aes.r
\name{aes_string}
\alias{aes_q}
\alias{aes_string}
\title{Define aesthetic mappings from a string/quoted objects}
\usage{
aes_string(x, y, ...)
aes_q(x = NULL, y = NULL, ...)
}
\arguments{
\item{x,y,...}{List of name value pairs}
}
\description{
Aesthetic mappings describe how variables in the data are mapped to visual
properties (aesthetics) of geoms. \code{\link{aes}} uses non-standard
evaluation to capture the variable names. These two variants use
regular evaluation, which is easier to use inside functions.
}
\details{
\code{aes_string} and \code{aes_q} are particularly useful when writing
functions that create plots because you can use strings or quoted
names/calls to define the aesthetic mappings, rather than having to use
\code{\link{substitute}} to generate a call to \code{aes()}.
}
\examples{
# Threee ways of generating the same aesthetics
aes(mpg, wt, col = cyl)
aes_string("mpg", "wt", col = "cyl")
aes_q(quote(mpg), quote(wt), col = quote(cyl))
# aes_string and aes_q are most useful when you have the name of a variable
# stored in a variable
var <- "cyl"
aes(col = x)
aes_string(col = var)
aes_q(col = as.name(var))
}
\seealso{
\code{\link{aes}}
Other aesthetic generators: \code{\link{aes}}
}