add.grf.function: Add function to GRF object

Description Usage Arguments Details Value Author(s) Examples

View source: R/add-grf-function.R

Description

Generates a function from the GRF object specified as a parameter, and adds it to the object.

Usage

1
add.grf.function(grf.object, function.name = NULL, seed = NULL)

Arguments

grf.object

A GRF object generated by generate.grf.object.

seed

Optional, the seed used for generating the function.

Details

The object chol.object, which is needed for computing the function, is computed and added to grf.object the first time that add.grf.function is run.

Value

The GRF object with the function 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
18
library(GRFics)
# Prepare GRF object
grf.object = generate.grf.object(0, 1, 0, 1, 100, 100)
# Add two functions to object
grf.object = add.grf.function(grf.object, seed = 0)
grf.object = add.grf.function(grf.object, seed = 1)
# Extract data frames
function.1.df = get.function.df(grf.object, function.number = 1)
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.