View source: R/boot_networklevel.r
boot_networklevel | R Documentation |
Takes a list of network interactions (each interaction being repeated as
many times as it was observed), and bootstraps the network level metric
(index
) for each network. Runs boot_networklevel_n()
for a list of
network interactions and prepares the data for plotting with ggplot
. The
output list can be passed to gg_networklevel
.
See examples below.
boot_networklevel(
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 |
The name of the network level metric. Passed to
|
level |
For which level should the level-specific indices be computed: 'both'
(default), 'lower' or 'higher'? 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 list of one (when level = 'lower'
or level = 'higher'
) or two
sub-lists (when level = 'both'
). The list can be passed to
gg_networklevel
. Each sub-list, 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), 10))]
set.seed(123)
Safariland_2 <- Safariland[, sort(sample.int(ncol(Safariland), 10))]
lst <- list(s1 = Safariland_1, s2 = Safariland_2) %>%
lapply(web_matrix_to_df) %>%
boot_networklevel(col_lower = "lower", # column name for plants
col_higher = "higher", # column name for insects
index = "nestedness",
level = "both",
start = 10,
step = 10,
n_boot = 10,
n_cpu = 2)
gg_networklevel(lst)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.