add.multiple.grf.functions: Add multiple functions to GRF object

Description Usage Arguments Details Value Author(s) Examples

View source: R/add-multiple-grf-functions.R

Description

Generates multiple functions from the GRF object specified as a parameter, and adds them to the object. See add.grf.function for details.

Usage

1
2
add.multiple.grf.functions(grf.object, num.functions = NULL,
  function.names = NULL, seed = NULL)

Arguments

grf.object

A GRF object generated by generate.grf.object.

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 num.functions (or length(function.names)).

Details

Either num.functions or function.names must be specified.

Value

The GRF object with the functions added to the functions list.

Author(s)

Mathias Isaksen mathiasleanderi@gmail.com

Examples

 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))

mathiasisaksen/GRFics documentation built on May 20, 2021, 5:55 a.m.