Description Usage Arguments Details Value Author(s) Examples
View source: R/add-grf-function.R
Generates a function from the GRF object specified as a parameter, and adds it to the object.
1 | add.grf.function(grf.object, function.name = NULL, seed = NULL)
|
grf.object |
A GRF object generated by |
seed |
Optional, the seed used for generating the function. |
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.
The GRF object with the function 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 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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.