Description Usage Arguments Examples
This function generates a multivariate plot for a data matrix (raster), with an option for filtering the data and to plot using groups. The resterplot graph is a flexible tool useful for different data sources.
1 2 3 4 5 6 7 8 9 10 11 12 |
x |
Data matrix (raster) |
filter |
Optional data matrix used as filter |
condition |
Condition used to filter data |
grp |
Factor with groups to use in the plot. Default NULL |
limits |
Balues limits used for computing the data gradient for the plot |
title |
Plot title |
z.name |
Name for the legend |
vertical |
Should the populations on the x axis be partitioned? Default TRUE. |
interactivePlot |
Show an interactive plot via plotly? (default: TRUE) |
... |
additional arguments |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | ## Not run:
data(eco.test)
require(ggplot2)
# using the ecogen object "eco" to perform a multiple-lsa
con <- eco.weight(eco[["XY"]], method = "knearest", k = 4, row.sd = TRUE)
test.lsa <- eco.lsa(eco[["P"]], con = con, method = "I", nsim = 99, multi = "matrix")
# the plot method for this object based in ggplot2, is a resterplot
eco.plotLocal(test.lsa, multi = "ggplot2")
# adding a factor
test.lsa <- eco.lsa(eco[["P"]], con = con, method = "I",
nsim = 99, multi = "matrix", pop = eco[["S"]][,1])
eco.plotLocal(test.lsa, multi = "ggplot2")
# The generic rasterplot method requires a data matrix, and, as option, a condition
# and a filter matrix. The condition is an expression, containing the word "filter" and
# logical elements, e.g., "filter < 50", "filter <50 || filter > 2", etc. ).
# Filter is used as a logical matrix (TRUE-FALSE, in relation to the passed condition),
# for filtering the data. If a condition is passed but not a filter matrix, the condition
# is applied over the data matrix, also using the word "filter".
# Internally, the multi.lsa plot uses three fundamental elements.
# - a data matrix: in the example, ecoslot.OBS(test.lsa)
# - a filter matrix: in the example, ecoslt.PVAL(test.lsa); i.e.,
# the data matrix will be filtered by P-value using the third element, an expresion.
# - an expression: in the example: "filter < 0.05"
# by combining the three elements, the multivariate plot can be manually constructed:
my.plot <- eco.rasterplot(x= ecoslot.OBS(test.lsa),
filter = ecoslot.PVAL(test.lsa), condition = "filter < 0.05")
my.plot
# add population
my.plot <- eco.rasterplot(x= ecoslot.OBS(test.lsa),
filter = ecoslot.PVAL(test.lsa),
condition = "filter < 0.05", grp = ecoslot.POP(test.lsa))
my.plot
# extra manipulation with ggplot2 graphs (ggplot2 commands allowed by rasterplot)
my.plot <- eco.rasterplot(x= ecoslot.OBS(test.lsa),
filter = ecoslot.PVAL(test.lsa), condition = "filter < 0.05",
interactivePlot = FALSE)
my.plot
## rotate plot
my.plot + coord_flip()
## change design
my.plot + theme_grey()
# using the data as filter
eco.rasterplot(x= ecoslot.OBS(test.lsa), filter = ecoslot.OBS(test.lsa),
condition = "filter > 0 & filter < 3")
# example of bad syntax (incorrect use of && over matrices)
eco.rasterplot(x= ecoslot.OBS(test.lsa), filter = ecoslot.OBS(test.lsa),
condition = "filter > 0 && filter < 3")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.