library(DImodels)
data(sim2)
# Fit model
mod <- DI(y = "response", prop = 3:6, DImodel = "AV", data = sim2)
# Create plot
# Move from p3 monoculture to p4 monoculture
simplex_path(model = mod,
starts = data.frame(p1 = 0, p2 = 0, p3 = 1, p4 = 0),
ends = data.frame(p1 = 0, p2 = 0, p3 = 0, p4 = 1))
# Move from each 70% dominant mixtures to p1 monoculture
simplex_path(model = mod,
starts = sim2[c(1, 5, 9, 13), 3:6],
ends = data.frame(p1 = 1, p2 = 0, p3 = 0, p4 = 0))
# Move from centroid community to each monoculture
simplex_path(model = mod,
starts = sim2[c(18),],
ends = sim2[c(48, 52, 56, 60), ])
# Show change across multiple points simultaneously and show confidence bands
# using `se = TRUE`
simplex_path(model = mod,
starts = sim2[c(1, 17, 22), ],
ends = sim2[c(5, 14, 17), ], se = TRUE)
# Change pie_colours using `pie_colours` and show pie-glyph at different
# points along the curve using `pie_positions`
simplex_path(model = mod,
starts = sim2[c(1, 17, 22), ],
ends = sim2[c(5, 14, 17), ], se = TRUE,
pie_positions = c(0, 0.25, 0.5, 0.75, 1),
pie_colours = c("steelblue1", "steelblue4", "orange1", "orange4"))
# Facet based on existing variables
# \donttest{
simplex_path(model = mod,
starts = sim2[c(1, 17, 22), ],
ends = sim2[c(5, 14, 17), ], se = TRUE, facet_var = "block",
pie_colours = c("steelblue1", "steelblue4", "orange1", "orange4"))
# Add additional variables and create a separate plot for each
simplex_path(model = mod,
starts = sim2[c(1, 17, 22), 3:6],
ends = sim2[c(5, 14, 17), 3:6], se = TRUE,
pie_colours = c("steelblue1", "steelblue4", "orange1", "orange4"),
add_var = list("block" = factor(c(1, 3),
levels = c(1, 2, 3, 4))))
# }
## Specify `plot = FALSE` to not create the plot but return the prepared data
head(simplex_path(model = mod, plot = FALSE,
starts = sim2[c(1, 17, 22), 3:6],
ends = sim2[c(5, 14, 17), 3:6], se = TRUE,
pie_colours = c("steelblue1", "steelblue4",
"orange1", "orange4"),
add_var = list("block" = factor(c(1, 3),
levels = c(1, 2, 3, 4)))))
Run the code above in your browser using DataLab