Description Usage Arguments Details Value Author(s) Examples
View source: R/add-multiple-grf-functions.R
Generates multiple functions from the GRF object specified as a parameter, and adds them to the object.
See add.grf.function
for details.
1 2 | add.multiple.grf.functions(grf.object, num.functions = NULL,
function.names = NULL, seed = NULL)
|
grf.object |
A GRF object generated by |
num.functions |
The number of functions to be added. |
function.names |
A character vector specifying the names used for each function. |
seed |
Optional. Must be a numeric vector of length |
Either num.functions
or function.names
must be specified.
The GRF object with the functions added to the functions
list.
Mathias Isaksen mathiasleanderi@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | library(GRFics)
# Prepare GRF object
grf.object = generate.grf.object(0, 1, 0, 1, 100, 100)
# Add two functions to object
grf.object = add.multiple.grf.functions(grf.object, function.names = c("u", "v"))
# Extract data frames
function.1.df = get.function.df(grf.object, function.name = "u")
function.2.df = get.function.df(grf.object, function.number = 2)
# Create combined data frame for plotting
combined.df = rbind(function.1.df, function.2.df)
combined.df$facet.var = rep(1:2, each = nrow(function.1.df))
# Plot functions side by side
library(ggplot2)
ggplot()+
geom_raster(data = combined.df, aes(x = x, y = y, fill = z))+
coord_fixed()+
facet_grid(cols = vars(facet.var))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.