Learn R Programming

yamlet (version 0.6.5)

ggready: Prepare Data for GGplot

Description

Prepares data for ggplot. Generic, with methods for data.frame, and decorated.

Usage

ggready(x, ...)

Arguments

x

object

...

passed arguments

Value

see methods

See Also

Other ggready: ggplot.ggready(), ggplot_build.ggready_ggplot(), ggready.data.frame(), ggready.decorated(), print.ggready_ggplot()

Examples

Run this code
# NOT RUN {
file <- system.file(package = 'yamlet', 'extdata','quinidine.csv')
x <- decorate(file)
decorations(x, Weight)
decorations(as.data.frame(x), Weight) # downgrade still has attributes
class(x)
class(ggready(as.data.frame(x)))
class(ggready(x))
class(ggready(resolve(x)))
x <- ggready(x)
library(magrittr)
library(ggplot2)

# Here we filter on-the-fly
# without loss of attributes.
# Notice mg/L rendering; this is actually part of an expression.
file %>%
 decorate %>%
 filter(!is.na(conc)) %>%
 ggready %>%
 ggplot(aes(x = time, y = conc, color = Heart)) +
 geom_point()

# By default ggready resolves everything decorated.
# But we can intervene to resolve selectively,
# And further intervene to 'ggready' selectively.
#
x <- file %>% decorate %>% filter(!is.na(conc))
x %>%
resolve(conc, time) %>%   # Heart left unresolved!
ggready(conc, Heart) %>%  # time left unreadied!
ggplot(aes(x = time, y = conc, color = Heart)) + geom_point()

# Still, all the labels were actually expressions:
x %>%
resolve(conc, time) %>%
ggready(conc, Heart) %>%
decorations(conc, time, Heart)
# }

Run the code above in your browser using DataLab