View source: R/boot_specieslevel.r
boot_specieslevel | R Documentation |
Takes a list of network interactions (each interaction being repeated as
many times as it was observed), and bootstraps the given species level
metric (index
) for each network. Runs boot_specieslevel_n()
for a list
of network interactions and prepares the data for plotting with ggplot
.
The output list can be passed to
gg_specieslevel_compare_webs
or to
get_stats_multi
and then its output to
gg_specieslevel_web_by_web
. See examples below.
boot_specieslevel(
lst,
col_lower,
col_higher,
index,
level,
start,
step,
n_boot,
n_cpu,
probs = c(0.025, 0.975),
...
)
lst |
A list of one or multiple data frames of interactions from which to build and sample web matrices. Each interaction (row in the data frame) must be repeated as many times as it was observed. E.g. if the interaction species_1 x species_2 was observed 5 times, then repeat that row 5 times within the data frame. |
col_lower |
Quoted column name in |
col_higher |
Quoted column name in |
index |
Passed to |
level |
Passed to |
start |
Integer. The sample size (number of interactions) to start the bootstrap
with. If the start sample size is small (e.g. 5 or 10), then first
iterations might results in NaN-s and warning messages are displayed.
Consider to set |
step |
Integer. Sample size (number of interactions) used to increase gradually the
sampled network until all interactions are sampled. If |
n_boot |
Number of desired bootstraps (50 or 100 can be enough). |
n_cpu |
Number of CPU-s to use for parallel processing. |
probs |
A numeric vector of two probabilities in |
... |
Other arguments passed to |
A 3 levels list of the same length as lst
. The list can be passed to
gg_specieslevel_compare_webs
or to
get_stats_multi
and then its output to
gg_specieslevel_web_by_web
. Each element of the
list is a sub-list corresponding to each network. Each sub-list contains
further sub-lists with the bootstrapped metric values at 'lower', 'higher'
or 'both' levels. Each sub-sub-lists contains two data frames: stats_df
and lines_df
, which can be used by the ggplot2::geom_line()
function.
See the return section of get_stats_single
for
more details about stats_df
and lines_df
data frames.
library(bootstrapnet)
library(bipartite)
library(magrittr)
data(Safariland)
set.seed(321)
Safariland_1 <- Safariland[, sort(sample.int(ncol(Safariland), 20))]
set.seed(123)
Safariland_2 <- Safariland[, sort(sample.int(ncol(Safariland), 20))]
lst <- list(s1 = Safariland_1, s2 = Safariland_2) %>%
lapply(web_matrix_to_df) %>%
boot_specieslevel(col_lower = "lower", # column name for plants
col_higher = "higher", # column name for insects
index = "betweenness",
level = "both",
start = 50,
step = 20,
n_boot = 10,
n_cpu = 2)
lst %>%
get_stats_multi() %>%
gg_specieslevel_compare_webs(sp_lower = "Alstroemeria aurea",
sp_higher = "Allograpta.Toxomerus")
lst %>%
gg_specieslevel_web_by_web(sp_lower = c("Alstroemeria aurea",
"Aristotelia chilensis"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.