diff --git a/DESCRIPTION b/DESCRIPTION index b8e5140..5389eed 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,7 +15,7 @@ Imports: broom, dplyr, ggplot2, magrittr, network, scales, sna, stats, tidyr, MA License: GPL (>= 2) Encoding: UTF-8 LazyData: true -RoxygenNote: 6.1.1 +RoxygenNote: 7.1.0 Suggests: knitr, rmarkdown, pkgdown VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index c44d6ad..eb32de2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -20,15 +20,17 @@ importFrom(dplyr,group_split) importFrom(dplyr,mutate) importFrom(dplyr,select) importFrom(dplyr,summarise) +importFrom(ggplot2,aes) importFrom(ggplot2,aes_string) importFrom(ggplot2,geom_line) importFrom(ggplot2,geom_point) importFrom(ggplot2,geom_ribbon) importFrom(ggplot2,ggplot) +importFrom(ggplot2,scale_color_manual) importFrom(ggplot2,scale_fill_manual) importFrom(ggplot2,scale_x_log10) importFrom(ggplot2,scale_y_log10) -importFrom(ggplot2,theme_classic) +importFrom(ggplot2,theme_bw) importFrom(ggplot2,xlab) importFrom(ggplot2,ylab) importFrom(ggplot2,ylim) diff --git a/R/Extintions.R b/R/Extintions.R index 615408c..887da6d 100644 --- a/R/Extintions.R +++ b/R/Extintions.R @@ -44,7 +44,7 @@ Mostconnected <- function(Network){ indegreetopnetzeros <- sum(degree(Network, cmode = "outdegree") == 0) Producers <- (1:length(degree(Network, cmode = "indegree")))[degree(Network, cmode = "indegree") == 0] TopPredators <- (1:length(degree(Network, cmode = "outdegree")))[degree(Network, cmode = "outdegree") == 0] - DF <- data.frame(Spp = rep(NA, network.size(Network)), nodesS = rep(NA, network.size(Network)), linksS = rep(NA, network.size(Network)), Conectance = rep(NA, network.size(Network)), LinksPerSpecies = rep(NA, network.size(Network)),Secondary_extinctions = rep(NA,network.size(Network)), Predation_release = rep(NA,network.size(Network)), isolated_nodes =rep (NA,network.size(Network))) + DF <- data.frame(Spp = rep(NA, network.size(Network)), S = rep(NA, network.size(Network)), L = rep(NA, network.size(Network)), C = rep(NA, network.size(Network)), Link_density = rep(NA, network.size(Network)),SecExt = rep(NA,network.size(Network)), Pred_release = rep(NA,network.size(Network)), Iso_nodes =rep (NA,network.size(Network))) Secundaryext <- c() Predationrel <- c() @@ -78,17 +78,17 @@ Mostconnected <- function(Network){ delete.vertices(Temp, unique(c(c(DF$Spp[1:i]),accExt))) } - DF$nodesS[i] <- network.size(Temp) - DF$linksS[i] <- network.edgecount(Temp) - DF$Conectance[i] <- network.density(Temp) - DF$LinksPerSpecies [i] <- DF$linksS[i]/DF$nodesS[i] + DF$S[i] <- network.size(Temp) + DF$L[i] <- network.edgecount(Temp) + DF$C[i] <- network.density(Temp) + DF$Link_density [i] <- DF$L[i]/DF$S[i] SecundaryextTemp <- (1:length(degree(Temp, cmode = "indegree")))[degree(Temp, cmode = "indegree") == 0] for(j in sort(unique(c(c(DF$Spp[1:i]),accExt)))){ SecundaryextTemp <- ifelse(SecundaryextTemp < j, SecundaryextTemp, SecundaryextTemp + 1) } Secundaryext <- SecundaryextTemp Secundaryext <- Secundaryext[!(Secundaryext %in% Producers)] - DF$Secondary_extinctions[i]<- length(Secundaryext) + DF$SecExt[i]<- length(Secundaryext) PredationrelTemp <- (1:length(degree(Temp, cmode = "outdegree")))[degree(Temp, cmode = "outdegree") == 0] for(j in sort(unique(c(c(DF$Spp[1:i]),accExt)))){ @@ -96,20 +96,20 @@ Mostconnected <- function(Network){ } Predationrel <- PredationrelTemp Predationrel <- Predationrel[!(Predationrel %in% TopPredators)] - DF$Predation_release[i]<- length(Predationrel) + DF$Pred_release[i]<- length(Predationrel) - DF$isolated_nodes[i] <- sum(degree(Temp) == 0) + DF$Iso_nodes[i] <- sum(degree(Temp) == 0) print(i) FinalExt[[i]] <-(Secundaryext) accExt <- append(accExt, DF$Spp[1:i]) accExt <- unique(append(accExt,Secundaryext)) - if (DF$linksS[i] == 0) break + if (DF$L[i] == 0) break } DF <- DF[complete.cases(DF),] - DF$AccSecondaryExtinction<- cumsum(DF$Secondary_extinctions) + DF$AccSecExt<- cumsum(DF$SecExt) DF$NumExt <- 1:nrow(DF) - DF$TotalExt <- DF$AccSecondaryExtinction + DF$NumExt + DF$TotalExt <- DF$AccSecExt + DF$NumExt class(DF) <- c("data.frame", "Mostconnected") return(DF) } @@ -136,7 +136,7 @@ Mostconnected <- function(Network){ #' @importFrom ggplot2 aes_string #' @importFrom ggplot2 geom_line #' @importFrom ggplot2 ggplot -#' @importFrom ggplot2 theme_classic +#' @importFrom ggplot2 theme_bw #' @importFrom ggplot2 xlab #' @importFrom ggplot2 ylab #' @importFrom network as.matrix.network.edgelist @@ -164,7 +164,7 @@ ExtinctionOrder <- function(Network, Order){ Producers <- (1:length(degree(Network, cmode = "indegree")))[degree(Network, cmode = "indegree") == 0] TopPredators <- (1:length(degree(Network, cmode = "outdegree")))[degree(Network, cmode = "outdegree") == 0] - DF <- data.frame(Spp = rep(NA, network.size(Network)), nodesS = rep(NA, network.size(Network)), linksS = rep(NA, network.size(Network)), Conectance = rep(NA, network.size(Network)), Secondary_extinctions = rep(NA,network.size(Network)), Predation_release = rep(NA,network.size(Network))) + DF <- data.frame(Spp = rep(NA, network.size(Network)), S = rep(NA, network.size(Network)), L = rep(NA, network.size(Network)), C = rep(NA, network.size(Network)), SecExt = rep(NA,network.size(Network)), Pred_release = rep(NA,network.size(Network))) Secundaryext <- c() Predationrel <- c() @@ -195,9 +195,9 @@ ExtinctionOrder <- function(Network, Order){ delete.vertices(Temp, unique(c(c(DF$Spp[1:i]),accExt))) } - DF$nodesS[i] <- network.size(Temp) - DF$linksS[i] <- network.edgecount(Temp) - DF$Conectance[i] <- network.density(Temp) + DF$S[i] <- network.size(Temp) + DF$L[i] <- network.edgecount(Temp) + DF$C[i] <- network.density(Temp) SecundaryextTemp <- (1:length(degree(Temp, cmode = "indegree")))[degree(Temp, cmode = "indegree") == 0] for(j in sort(unique(c(c(DF$Spp[1:i]),accExt)))){ @@ -205,7 +205,7 @@ ExtinctionOrder <- function(Network, Order){ } Secundaryext <- SecundaryextTemp Secundaryext <- Secundaryext[!(Secundaryext %in% Producers)] - DF$Secondary_extinctions[i]<- length(Secundaryext) + DF$SecExt[i]<- length(Secundaryext) PredationrelTemp <- (1:length(degree(Temp, cmode = "outdegree")))[degree(Temp, cmode = "outdegree") == 0] for(j in sort(unique(c(c(DF$Spp[1:i]),accExt)))){ @@ -213,20 +213,20 @@ ExtinctionOrder <- function(Network, Order){ } Predationrel <- PredationrelTemp Predationrel <- Predationrel[!(Predationrel %in% TopPredators)] - DF$Predation_release[i]<- length(Predationrel) + DF$Pred_release[i]<- length(Predationrel) message(i) FinalExt[[i]] <-(Secundaryext) accExt <- append(accExt, DF$Spp[1:i]) accExt <- unique(append(accExt,Secundaryext)) - if (DF$linksS[i] == 0) break + if (DF$L[i] == 0) break } DF <- DF[complete.cases(DF),] - DF$AccSecondaryExtinction <- cumsum(DF$Secondary_extinctions) + DF$AccSecExt <- cumsum(DF$SecExt) DF$NumExt <- 1:nrow(DF) - DF$TotalExt <- DF$AccSecondaryExtinction + DF$NumExt - G <- ggplot(DF, aes_string(x = "NumExt", y = "AccSecondaryExtinction")) + geom_line() + ylab("Secondary extinctions") + xlab("number of extinctions") + theme_classic() + DF$TotalExt <- DF$AccSecExt + DF$NumExt + G <- ggplot(DF, aes_string(x = "NumExt", y = "AccSecExt")) + geom_line() + ylab("Acc. Secondary extinctions") + xlab("Primary extinctions") + theme_bw() Results <- list(DF= DF, Graph = G) class(Results) <- c("ExtinctionOrder") return(Results) @@ -253,8 +253,10 @@ ExtinctionOrder <- function(Network, Order){ #' @importFrom ggplot2 geom_line #' @importFrom ggplot2 geom_ribbon #' @importFrom ggplot2 ggplot -#' @importFrom ggplot2 theme_classic +#' @importFrom ggplot2 theme_bw #' @importFrom ggplot2 scale_fill_manual +#' @importFrom ggplot2 xlab +#' @importFrom ggplot2 ylab #' @importFrom magrittr "%>%" #' @importFrom network network.size #' @importFrom scales muted @@ -264,7 +266,7 @@ ExtinctionOrder <- function(Network, Order){ #' @export RandomExtinctions <- function(Network, nsim = 10){ - NumExt <- sd <- AccSecondaryExtinction <- NULL + NumExt <- sd <- AccSecExt <- NULL network <- Network sims <- list() for(i in 1:nsim){ @@ -275,8 +277,8 @@ RandomExtinctions <- function(Network, nsim = 10){ cond <- sapply(sims, function(x) class(x) == "data.frame") sims <- sims[cond] sims <- do.call(rbind, sims) - sims <- sims %>% group_by(NumExt) %>% summarise(SdAccSecondaryExtinction = sd(AccSecondaryExtinction), AccSecondaryExtinction = mean(AccSecondaryExtinction)) - g <- ggplot(sims, aes_string(x = "NumExt", y = "AccSecondaryExtinction")) + geom_ribbon(aes_string(ymin = "AccSecondaryExtinction - SdAccSecondaryExtinction", ymax = "AccSecondaryExtinction + SdAccSecondaryExtinction"), fill = muted("red")) + geom_line() + theme_classic() + sims <- sims %>% group_by(NumExt) %>% summarise(AccSecExt_sd = sd(AccSecExt), AccSecExt_mean = mean(AccSecExt)) + g <- ggplot(sims, aes_string(x = "NumExt", y = "AccSecExt_mean")) + geom_ribbon(aes_string(ymin = "AccSecExt_mean - AccSecExt_sd", ymax = "AccSecExt_mean + AccSecExt_sd"), fill = muted("red")) + geom_line() + ylab("Acc. Secondary extinctions") + xlab("Primary extinctions") + theme_bw() g return(list(sims = sims, graph = g)) } @@ -303,8 +305,10 @@ RandomExtinctions <- function(Network, nsim = 10){ #' #' CompareExtinctions(Nullmodel = NullHyp, Hypothesis = History) #' @importFrom broom tidy +#' @importFrom ggplot2 aes #' @importFrom ggplot2 geom_line #' @importFrom ggplot2 geom_point +#' @importFrom ggplot2 scale_color_manual #' @importFrom stats chisq.test #' @author Derek Corcoran #' @author M.Isidora Avila Thieme @@ -312,19 +316,19 @@ RandomExtinctions <- function(Network, nsim = 10){ CompareExtinctions <- function(Nullmodel, Hypothesis){ if(class(Hypothesis)[1] == "ExtinctionOrder"){ - NumExt <- sd <- AccSecondaryExtinction <- NULL - g <- Nullmodel$graph - g <- g + geom_point(data = Hypothesis$DF) + geom_line(data = Hypothesis$DF, lty = 2) + NumExt <- sd <- AccSecExt <- AccSecExt_mean <-NULL + g <- Nullmodel$graph + geom_line(aes(color = "blue")) + g <- g + geom_point(data = Hypothesis$DF, aes(y = AccSecExt), color = "blue") + geom_line(data = Hypothesis$DF, aes(y = AccSecExt, color = "black")) + scale_color_manual(values =c("blue", "black"), label = c("Observed","Null hypothesis")) g - Test <- chisq.test(x = Hypothesis$DF$AccSecondaryExtinction, y = Nullmodel$sims$AccSecondaryExtinction[1:length(Hypothesis$DF$AccSecondaryExtinction)]) + Test <- chisq.test(x = Hypothesis$DF$AccSecExt, y = Nullmodel$sims$AccSecExt_mean[1:length(Hypothesis$DF$AccSecExt)]) return(list(Test = Test, graph = g)) } if(class(Hypothesis)[2] == "Mostconnected"){ - NumExt <- sd <- AccSecondaryExtinction <- NULL - g <- Nullmodel$graph - g <- g + geom_point(data = Hypothesis) + geom_line(data = Hypothesis, lty = 2) + NumExt <- sd <- AccSecExt <- AccSecExt_mean <-NULL + g <- Nullmodel$graph + geom_line(aes(color = "blue")) + g <- g + geom_point(data = Hypothesis, aes(y = AccSecExt), color = "blue") + geom_line(data = Hypothesis, aes(y = AccSecExt, color = "black")) + scale_color_manual(values =c("blue", "black"), label = c("Observed","Null hypothesis")) g - Test <- tidy(chisq.test(x = Hypothesis$AccSecondaryExtinction, y = Nullmodel$sims$AccSecondaryExtinction[1:length(Hypothesis$AccSecondaryExtinction)])) + Test <- tidy(chisq.test(x = Hypothesis$AccSecExt, y = Nullmodel$sims$AccSecExt_mean[1:length(Hypothesis$AccSecExt)])) return(list(Test = Test, graph = g)) } else{ diff --git a/R/Plots.R b/R/Plots.R index 6690411..5956cbf 100644 --- a/R/Plots.R +++ b/R/Plots.R @@ -14,17 +14,17 @@ #' history <- Mostconnected(Network = net) #' ExtinctionPlot(History = history) #' # You can also specify the variable to be ploted in the y axis -#' ExtinctionPlot(History = history, Variable = "LinksPerSpecies") +#' ExtinctionPlot(History = history, Variable = "Link_density") #' @importFrom ggplot2 aes_string #' @importFrom ggplot2 geom_line #' @importFrom ggplot2 ggplot -#' @importFrom ggplot2 theme_classic +#' @importFrom ggplot2 theme_bw #' @author Derek Corcoran #' @author M.Isidora Avila Thieme #' @seealso [NetworkExtintion::ExtinctionOrder()] #' @export -ExtinctionPlot <- function(History, Variable = "AccSecondaryExtinction"){ +ExtinctionPlot <- function(History, Variable = "AccSecExt"){ History$X <- 1:nrow(History) - ggplot(History, aes_string(x = "X", y = Variable)) + geom_line() + theme_classic() + ylab(Variable) + xlab("Number of extinctions") + ggplot(History, aes_string(x = "X", y = Variable)) + geom_line() + theme_bw() + ylab(Variable) + xlab("Primary extinctions") } diff --git a/R/Powerlaw.R b/R/Powerlaw.R index 5688cdc..c11dc0e 100644 --- a/R/Powerlaw.R +++ b/R/Powerlaw.R @@ -41,7 +41,7 @@ #'@importFrom ggplot2 geom_point #'@importFrom ggplot2 scale_x_log10 #'@importFrom ggplot2 scale_y_log10 -#'@importFrom ggplot2 theme_classic +#'@importFrom ggplot2 theme_bw #'@importFrom ggplot2 ylim #'@importFrom MASS fitdistr #'@importFrom purrr map @@ -127,7 +127,7 @@ degree_distribution <- function(Network, scale = "arithmetic"){ params <- bind_rows(Params.logpower, Params.power, Params.exp, Params.logexp) %>% dplyr::filter(model %in% Summs$model) DF2 <- For.Graph %>% filter(K != 0 & Cumulative != 0) %>% gather(key = model, value = fit, Exp, Power, LogExp, LogPower) %>% dplyr::filter(model %in% Summs$model) - g <- ggplot(DF2, aes_string(x = "K", y = "Cumulative")) + geom_line() + geom_point()+ theme_classic() + geom_line(aes_string(y ="fit", color = "model")) + ylim(c(0,1)) + g <- ggplot(DF2, aes_string(x = "K", y = "Cumulative")) + geom_line() + geom_point()+ theme_bw() + geom_line(aes_string(y ="fit", color = "model")) + ylim(c(0,1)) if(scale == "LogLog"){ g <- g + scale_x_log10() + scale_y_log10(breaks=c(0, .001,.01,1)) diff --git a/docs/404.html b/docs/404.html index 3991f46..e1e4285 100644 --- a/docs/404.html +++ b/docs/404.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -44,7 +48,6 @@ - @@ -62,7 +65,7 @@ - +
+ +
@@ -139,7 +148,7 @@

Page not found (404)

-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.5.1.

diff --git a/docs/articles/How_to_use_the_NetworkExtinction_Package.html b/docs/articles/How_to_use_the_NetworkExtinction_Package.html index 64be76e..d962df8 100644 --- a/docs/articles/How_to_use_the_NetworkExtinction_Package.html +++ b/docs/articles/How_to_use_the_NetworkExtinction_Package.html @@ -12,20 +12,20 @@ - - - - + + + + + - + - - +

@@ -139,47 +139,51 @@

In order to create a network object you can start with a matrix or an edgelist object (for more details see the network package vignette).

As an example of how to build a food web we will explain how to create the network shown in figure 1.

-Figure 1. Food-web to be contructed in R

Figure 1. Food-web to be contructed in R

+Figure 1. Food-web to be contructed in R

+Figure 1. Food-web to be contructed in R +

This network has ten nodes where each node represents one species. Here, four nodes are basal species (primary producers, from sp.1 to sp.4), three nodes are intermediate (primary consumers, from sp.5 to sp.7), and the remaining three are top predators (from sp.8 to sp.10).

In order to build an interaction matrix (Figure 2) that represent the food web, we create a square matrix with a column and a row representing each species. Columns represent the consumers and the rows the resources, where 1 represents a trophic interaction and 0 its absence. Note that in the columns, the first four species only have zeros because they are not consumers. For example, if we look at species 7, it feeds on species 4 and 3. In order to represent that, we would go to column 7 and put a 1 in rows 3 and 4.

-Figure 2. Matrix representation of the food web

Figure 2. Matrix representation of the food web

+Figure 2. Matrix representation of the food web

+Figure 2. Matrix representation of the food web +

The following code is an example of how to build the matrix in figure 2 using R:

-
a<- matrix(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0),nrow=10, ncol=10)
-
-a
-#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
-#>  [1,]    0    0    0    0    1    0    0    0    0     0
-#>  [2,]    0    0    0    0    0    1    0    0    0     1
-#>  [3,]    0    0    0    0    0    0    1    0    0     0
-#>  [4,]    0    0    0    0    0    0    1    0    0     0
-#>  [5,]    0    0    0    0    0    0    0    1    0     0
-#>  [6,]    0    0    0    0    0    0    0    1    1     0
-#>  [7,]    0    0    0    0    0    0    0    0    0     1
-#>  [8,]    0    0    0    0    0    0    0    0    0     1
-#>  [9,]    0    0    0    0    0    0    0    0    0     0
-#> [10,]    0    0    0    0    0    0    0    0    0     0
+
a<- matrix(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0),nrow=10, ncol=10)
+
+a
+#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
+#>  [1,]    0    0    0    0    1    0    0    0    0     0
+#>  [2,]    0    0    0    0    0    1    0    0    0     1
+#>  [3,]    0    0    0    0    0    0    1    0    0     0
+#>  [4,]    0    0    0    0    0    0    1    0    0     0
+#>  [5,]    0    0    0    0    0    0    0    1    0     0
+#>  [6,]    0    0    0    0    0    0    0    1    1     0
+#>  [7,]    0    0    0    0    0    0    0    0    0     1
+#>  [8,]    0    0    0    0    0    0    0    0    0     1
+#>  [9,]    0    0    0    0    0    0    0    0    0     0
+#> [10,]    0    0    0    0    0    0    0    0    0     0

Once the matrix is ready, we use the as.network function from the network package to build a network object.

- +
library(network)
+net <- as.network(a, loops = TRUE)
+net
+#>  Network attributes:
+#>   vertices = 10 
+#>   directed = TRUE 
+#>   hyper = FALSE 
+#>   loops = TRUE 
+#>   multiple = FALSE 
+#>   bipartite = FALSE 
+#>   total edges= 10 
+#>     missing edges= 0 
+#>     non-missing edges= 10 
+#> 
+#>  Vertex attribute names: 
+#>     vertex.names 
+#> 
+#> No edge attributes

@@ -192,9 +196,9 @@

Extinctions from most to less conected species in the network

The Mostconnected function sorts the species from the most connected node to the least connected node, using total degree. Then, it removes the most connected node in the network, simulating its extinction, and recalculates the topological indexes of the network and counts how many species have indegree 0 (secondary extinction), not considering primary producers. Then, it removes the nodes that were secondarily extinct in the previous step and recalculates which node is the new most connected species. This step is repeated until the number of links in the network is zero (Sole and Montoya 2001; Dunne, Williams, and Martinez 2002; Dunne and Williams 2009).

-
library(NetworkExtinction)
-data("net")
-Mostconnected(Network = net)
+
library(NetworkExtinction)
+data("net")
+Mostconnected(Network = net)
#> [1] 1
 #> [1] 2
 #> [1] 3
@@ -203,14 +207,14 @@ 

Table 1: The resulting dataframe of the Mostconnected function Spp -nodesS -linksS -Conectance -LinksPerSpecies -Secondary_extinctions -Predation_release -isolated_nodes -AccSecondaryExtinction +S +L +C +Link_density +SecExt +Pred_release +Iso_nodes +AccSecExt NumExt TotalExt @@ -270,13 +274,13 @@

The result of this function is the dataframe shown in table 1. The first column called Spp indicates the order in which the species were removed simulating an extinction. The column Secondary_extinctions represents the numbers of species that become extinct given that they do not have any food items left in the food web, while the AccSecondaryExtinction column represents the accumulated secondary extinctions. (To plot the results, see function ExtinctionPlot.)

-
data("net")
-history <- Mostconnected(Network = net)
-#> [1] 1
-#> [1] 2
-#> [1] 3
-#> [1] 4
-ExtinctionPlot(History = history, Variable = "AccSecondaryExtinction")
+
data("net")
+history <- Mostconnected(Network = net)
+#> [1] 1
+#> [1] 2
+#> [1] 3
+#> [1] 4
+ExtinctionPlot(History = history, Variable = "AccSecExt")
Figure 3. The graph shows the number of accumulated secondary extinctions that occur when removing species from the most to the least connected species

Figure 3. The graph shows the number of accumulated secondary extinctions that occur when removing species from the most to the least connected species @@ -287,18 +291,18 @@

Extinctions using a customized order

The ExtinctionOrder function takes a network and extinguishes nodes using a customized order. Then, it calculates the topological network indexes and the secondary extinctions.

-
data("net")
-ExtinctionOrder(Network = net, Order = c(2,4,7))
+
data("net")
+ExtinctionOrder(Network = net, Order = c(2,4,7))
- - - - - - + + + + + + @@ -349,14 +353,14 @@

Random extinction

The RandomExtinctions function generates n random extinction orders, determined by the argument nsim. The first result of this function is a dataframe (table 3). The column NumExt represents the number of species removed, AccSecondaryExtinction is the average number of secondary extinctions for each species removed, and SdAccSecondaryExtinction is its standard deviation. The second result is a graph (figure 5), where the x axis is the number of species removed and the y axis is the number of accumulated secondary extinctions. The solid line is the average number of secondary extinctions for every simulated primary extinction, and the red area represents the mean \(\pm\) the standard deviation of the simulations.

-
data(net)
-RandomExtinctions(Network= net, nsim= 50)
+
data(net)
+RandomExtinctions(Network= net, nsim= 50)
Table 2: The resulting dataframe of the ExtinctionOrder function
SppnodesSlinksSConectanceSecondary_extinctionsPredation_releaseAccSecondaryExtinctionSLCSecExtPred_releaseAccSecExt NumExt TotalExt
- - + + @@ -416,13 +420,13 @@

Comparison of Null hypothesis with other extinction histories

The RandomExtinctons function generates a null hypothesis for us to compare it with either an extinction history generated by the ExtinctionOrder function or the Mostconnected function. In order to compare the expected extinctions developed by our null hypothesis with the observed extinction history, we developed the CompareExtinctions function. The way to use this last function is to first create the extinction history and the null hypothesis, and then the CompareExtinctins function to compare both extinction histories.

-
data("net")
-History <- ExtinctionOrder(Network = net, Order = c(1,2,3,4,5,6,7,8,9,10))
-
-set.seed(2)
-NullHyp <- RandomExtinctions(Network = net, nsim = 100)
-
-Comparison <- CompareExtinctions(Nullmodel = NullHyp, Hypothesis = History)
+
data("net")
+History <- ExtinctionOrder(Network = net, Order = c(1,2,3,4,5,6,7,8,9,10))
+
+set.seed(2)
+NullHyp <- RandomExtinctions(Network = net, nsim = 100)
+
+Comparison <- CompareExtinctions(Nullmodel = NullHyp, Hypothesis = History)

The first result will be a graph (Figue 6) with a dashed line showing the observed extinction history and a solid line showing the expected value of secondary extinctions randomly generated.

The second result will be a Test object which will show the goodness of fit statistics of the comparison. In this case, since the p value is 0.22 which is larger than 0.05, we consider that the generated extinction history is significantly different than the null hypothesis.

@@ -430,31 +434,31 @@

Figure 6. The resulting graph of the CompareExtinctions function, where the dashed line shows the observed extinction history, and a solid line shows the expected value of secondary extinctions originated at random

- +
Comparison$Test
+#> 
+#>  Pearson's Chi-squared test
+#> 
+#> data:  Hypothesis$DF$AccSecExt and Nullmodel$sims$AccSecExt_mean[1:length(Hypothesis$DF$AccSecExt)]
+#> X-squared = 20, df = 16, p-value = 0.2202

Plotting the extinction histories of a network

The ExtinctionPlot function takes a NetworkTopology class object and plots the index of interest after every extinction. By default, the function plots the number of accumulated secondary extinctions after every primary extinction (Figure 7), but any of the indexes can be ploted with the function by changing the Variable argument (Figure 8).

-
data(net)
-history <- Mostconnected(Network = net)
-#> [1] 1
-#> [1] 2
-#> [1] 3
-#> [1] 4
-ExtinctionPlot(History = history)
+
data(net)
+history <- Mostconnected(Network = net)
+#> [1] 1
+#> [1] 2
+#> [1] 3
+#> [1] 4
+ExtinctionPlot(History = history)
Figure 7. Example of the use of the ExtinctionPlot function showing the accumulated secondary extinctions against number of extinctions

Figure 7. Example of the use of the ExtinctionPlot function showing the accumulated secondary extinctions against number of extinctions

-
ExtinctionPlot(History = history, Variable = "LinksPerSpecies")
+
ExtinctionPlot(History = history, Variable = "Link_density")
Figure 8. Another example of the use of the ExtinctionPlot function showing the number of links per species against number of extinctions

Figure 8. Another example of the use of the ExtinctionPlot function showing the number of links per species against number of extinctions @@ -466,8 +470,8 @@

Degree distribution function

The degree_distribution function calculates the cumulative distribution of the number of links that each species in the food network has (Estrada 2007). Then, the observed distribution is fitted to the exponential, and power law models.

The results of this function are shown in figure 9 and table 4. The graph shows the observed degree distribution in a log log scale fitting the three models mentioned above, for this example we use an example dataset of Chilean litoral rocky shores (Kéfi et al. 2015). The table shows the fitted model information ordered by descending AIC, that is, the model in the first row is the most probable distribution, followed by the second an finally the third distribution in this case (Table 3), the Exponential distribution would be the best model, followed by the Power law model.

-
data("chilean_intertidal")
-degree_distribution(chilean_intertidal)
+
data("chilean_intertidal")
+degree_distribution(chilean_intertidal)
Figure 9: Fitted vs observed values of the degree distribution. The black line and points show the observed values, the red, green and blue lines show the fitted values for the Exponential, power law and trucated distribution, respectively

Figure 9: Fitted vs observed values of the degree distribution. The black line and points show the observed values, the red, green and blue lines show the fitted values for the Exponential, power law and trucated distribution, respectively @@ -537,29 +541,11 @@

- @@ -570,7 +556,7 @@

-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.5.1.

diff --git a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-12-1.png b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-12-1.png index 6ac0254..d731b92 100644 Binary files a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-12-1.png and b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-12-1.png differ diff --git a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-14-1.png b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-14-1.png index dc9d131..588dc6f 100644 Binary files a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-14-1.png and b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-14-1.png differ diff --git a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-16-1.png b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-16-1.png index 8c14d40..ab816fd 100644 Binary files a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-16-1.png and b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-16-1.png differ diff --git a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-17-1.png b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-17-1.png index 98aa0dc..2661197 100644 Binary files a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-17-1.png and b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-17-1.png differ diff --git a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-20-1.png b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-20-1.png index ff752c5..a286f8b 100644 Binary files a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-20-1.png and b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-20-1.png differ diff --git a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-6-1.png index 8c14d40..ab816fd 100644 Binary files a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-9-1.png b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-9-1.png index 6f6d84b..c5011ba 100644 Binary files a/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-9-1.png and b/docs/articles/How_to_use_the_NetworkExtinction_Package_files/figure-html/unnamed-chunk-9-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index 93a475a..dc81bc8 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -44,7 +48,6 @@ - @@ -62,7 +65,7 @@ - +
@@ -143,7 +147,7 @@

All vignettes

-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.5.1.

diff --git a/docs/authors.html b/docs/authors.html index f93483a..4d754e3 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -44,7 +48,6 @@ - @@ -62,7 +65,7 @@ - +
-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.5.1.

diff --git a/docs/bootstrap-toc.css b/docs/bootstrap-toc.css new file mode 100644 index 0000000..5a85941 --- /dev/null +++ b/docs/bootstrap-toc.css @@ -0,0 +1,60 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ + +/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ + +/* All levels of nav */ +nav[data-toggle='toc'] .nav > li > a { + display: block; + padding: 4px 20px; + font-size: 13px; + font-weight: 500; + color: #767676; +} +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 19px; + color: #563d7c; + text-decoration: none; + background-color: transparent; + border-left: 1px solid #563d7c; +} +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 18px; + font-weight: bold; + color: #563d7c; + background-color: transparent; + border-left: 2px solid #563d7c; +} + +/* Nav: second level (shown on .active) */ +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} +nav[data-toggle='toc'] .nav .nav > li > a { + padding-top: 1px; + padding-bottom: 1px; + padding-left: 30px; + font-size: 12px; + font-weight: normal; +} +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 29px; +} +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 28px; + font-weight: 500; +} + +/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ +nav[data-toggle='toc'] .nav > .active > ul { + display: block; +} diff --git a/docs/bootstrap-toc.js b/docs/bootstrap-toc.js new file mode 100644 index 0000000..1cdd573 --- /dev/null +++ b/docs/bootstrap-toc.js @@ -0,0 +1,159 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ +(function() { + 'use strict'; + + window.Toc = { + helpers: { + // return all matching elements in the set, or their descendants + findOrFilter: function($el, selector) { + // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ + // http://stackoverflow.com/a/12731439/358804 + var $descendants = $el.find(selector); + return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); + }, + + generateUniqueIdBase: function(el) { + var text = $(el).text(); + var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); + return anchor || el.tagName.toLowerCase(); + }, + + generateUniqueId: function(el) { + var anchorBase = this.generateUniqueIdBase(el); + for (var i = 0; ; i++) { + var anchor = anchorBase; + if (i > 0) { + // add suffix + anchor += '-' + i; + } + // check if ID already exists + if (!document.getElementById(anchor)) { + return anchor; + } + } + }, + + generateAnchor: function(el) { + if (el.id) { + return el.id; + } else { + var anchor = this.generateUniqueId(el); + el.id = anchor; + return anchor; + } + }, + + createNavList: function() { + return $(''); + }, + + createChildNavList: function($parent) { + var $childList = this.createNavList(); + $parent.append($childList); + return $childList; + }, + + generateNavEl: function(anchor, text) { + var $a = $(''); + $a.attr('href', '#' + anchor); + $a.text(text); + var $li = $('
  • '); + $li.append($a); + return $li; + }, + + generateNavItem: function(headingEl) { + var anchor = this.generateAnchor(headingEl); + var $heading = $(headingEl); + var text = $heading.data('toc-text') || $heading.text(); + return this.generateNavEl(anchor, text); + }, + + // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). + getTopLevel: function($scope) { + for (var i = 1; i <= 6; i++) { + var $headings = this.findOrFilter($scope, 'h' + i); + if ($headings.length > 1) { + return i; + } + } + + return 1; + }, + + // returns the elements for the top level, and the next below it + getHeadings: function($scope, topLevel) { + var topSelector = 'h' + topLevel; + + var secondaryLevel = topLevel + 1; + var secondarySelector = 'h' + secondaryLevel; + + return this.findOrFilter($scope, topSelector + ',' + secondarySelector); + }, + + getNavLevel: function(el) { + return parseInt(el.tagName.charAt(1), 10); + }, + + populateNav: function($topContext, topLevel, $headings) { + var $context = $topContext; + var $prevNav; + + var helpers = this; + $headings.each(function(i, el) { + var $newNav = helpers.generateNavItem(el); + var navLevel = helpers.getNavLevel(el); + + // determine the proper $context + if (navLevel === topLevel) { + // use top level + $context = $topContext; + } else if ($prevNav && $context === $topContext) { + // create a new level of the tree and switch to it + $context = helpers.createChildNavList($prevNav); + } // else use the current $context + + $context.append($newNav); + + $prevNav = $newNav; + }); + }, + + parseOps: function(arg) { + var opts; + if (arg.jquery) { + opts = { + $nav: arg + }; + } else { + opts = arg; + } + opts.$scope = opts.$scope || $(document.body); + return opts; + } + }, + + // accepts a jQuery object, or an options object + init: function(opts) { + opts = this.helpers.parseOps(opts); + + // ensure that the data attribute is in place for styling + opts.$nav.attr('data-toggle', 'toc'); + + var $topContext = this.helpers.createChildNavList(opts.$nav); + var topLevel = this.helpers.getTopLevel(opts.$scope); + var $headings = this.helpers.getHeadings(opts.$scope, topLevel); + this.helpers.populateNav($topContext, topLevel, $headings); + } + }; + + $(function() { + $('nav[data-toggle="toc"]').each(function(i, el) { + var $nav = $(el); + Toc.init($nav); + }); + }); +})(); diff --git a/docs/index.html b/docs/index.html index 5b96eaf..bbee6b6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -12,21 +12,21 @@ - - - - + + + + + - - +

    Table 3: The resulting dataframe of the RandomExtinctions function
    NumExtSdAccSecondaryExtinctionAccSecondaryExtinctionAccSecExt_sdAccSecExt_mean

    Table 1: The resulting dataframe of the Mostconnected function

    The result of this function is the dataframe shown in table 1. The first column called Spp indicates the order in which the species were removed simulating an extinction. The column Secondary_extinctions represents the numbers of species that become extinct given that they do not have any food items left in the food web, while the AccSecondaryExtinction column represents the accumulated secondary extinctions. (To plot the results, see function ExtinctionPlot.)

    -
    data("net")
    -history <- Mostconnected(Network = net)
    -#> [1] 1
    -#> [1] 2
    -#> [1] 3
    -#> [1] 4
    -ExtinctionPlot(History = history, Variable = "AccSecondaryExtinction")
    +
    data("net")
    +history <- Mostconnected(Network = net)
    +#> [1] 1
    +#> [1] 2
    +#> [1] 3
    +#> [1] 4
    +ExtinctionPlot(History = history, Variable = "AccSecondaryExtinction")

    Figure 3. The graph shows the number of accumulated secondary extinctions that occur when removing species from the most to the least connected species

    Extinctions using a customized order

    The ExtinctionOrder function takes a network and extinguishes nodes using a customized order. Then, it calculates the topological network indexes and the secondary extinctions.

    -
    data("net")
    -ExtinctionOrder(Network = net, Order = c(2,4,7))
    +
    data("net")
    +ExtinctionOrder(Network = net, Order = c(2,4,7))
    @@ -282,9 +282,9 @@

    Random extinction

    -

    The RandomExtinctions function generates n random extinction orders, determined by the argument nsim. The first result of this function is a dataframe (table 3). The column NumExt represents the number of species removed, AccSecondaryExtinction is the average number of secondary extinctions for each species removed, and SdAccSecondaryExtinction is its standard deviation. The second result is a graph (figure 5), where the x axis is the number of species removed and the y axis is the number of accumulated secondary extinctions. The solid line is the average number of secondary extinctions for every simulated primary extinction, and the red area represents the mean (\pm) the standard deviation of the simulations.

    -
    data(net)
    -RandomExtinctions(Network= net, nsim= 50)
    +

    The RandomExtinctions function generates n random extinction orders, determined by the argument nsim. The first result of this function is a dataframe (table 3). The column NumExt represents the number of species removed, AccSecondaryExtinction is the average number of secondary extinctions for each species removed, and SdAccSecondaryExtinction is its standard deviation. The second result is a graph (figure 5), where the x axis is the number of species removed and the y axis is the number of accumulated secondary extinctions. The solid line is the average number of secondary extinctions for every simulated primary extinction, and the red area represents the mean ± the standard deviation of the simulations.

    +
    data(net)
    +RandomExtinctions(Network= net, nsim= 50)

    @@ -343,37 +343,37 @@

    Figure 5. The resulting graph of the RandomExtinctions function

    ###Comparison of Null hypothesis with other extinction histories

    The RandomExtinctons function generates a null hypothesis for us to compare it with either an extinction history generated by the ExtinctionOrder function or the Mostconnected function. In order to compare the expected extinctions developed by our null hypothesis with the observed extinction history, we developed the CompareExtinctions function. The way to use this last function is to first create the extinction history and the null hypothesis, and then the CompareExtinctins function to compare both extinction histories.

    -
    data("net")
    -History <- ExtinctionOrder(Network = net, Order = c(1,2,3,4,5,6,7,8,9,10))
    -
    -set.seed(2)
    -NullHyp <- RandomExtinctions(Network = net, nsim = 100)
    -
    -Comparison <- CompareExtinctions(Nullmodel = NullHyp, Hypothesis = History)
    +
    data("net")
    +History <- ExtinctionOrder(Network = net, Order = c(1,2,3,4,5,6,7,8,9,10))
    +
    +set.seed(2)
    +NullHyp <- RandomExtinctions(Network = net, nsim = 100)
    +
    +Comparison <- CompareExtinctions(Nullmodel = NullHyp, Hypothesis = History)

    The first result will be a graph (Figue 6) with a dashed line showing the observed extinction history and a solid line showing the expected value of secondary extinctions randomly generated.

    The second result will be a Test object which will show the goodness of fit statistics of the comparison. In this case, since the p value is 0.22 which is larger than 0.05, we consider that the generated extinction history is significantly different than the null hypothesis.

    Figure 6. The resulting graph of the CompareExtinctions function, where the dashed line shows the observed extinction history, and a solid line shows the expected value of secondary extinctions originated at random

    - +
    Comparison$Test
    +#> 
    +#>  Pearson's Chi-squared test
    +#> 
    +#> data:  Hypothesis$DF$AccSecondaryExtinction and Nullmodel$sims$AccSecondaryExtinction[1:length(Hypothesis$DF$AccSecondaryExtinction)]
    +#> X-squared = 20, df = 16, p-value = 0.2202

    Plotting the extinction histories of a network

    The ExtinctionPlot function takes a NetworkTopology class object and plots the index of interest after every extinction. By default, the function plots the number of accumulated secondary extinctions after every primary extinction (Figure 7), but any of the indexes can be ploted with the function by changing the Variable argument (Figure 8).

    -
    data(net)
    -history <- Mostconnected(Network = net)
    -#> [1] 1
    -#> [1] 2
    -#> [1] 3
    -#> [1] 4
    -ExtinctionPlot(History = history)
    +
    data(net)
    +history <- Mostconnected(Network = net)
    +#> [1] 1
    +#> [1] 2
    +#> [1] 3
    +#> [1] 4
    +ExtinctionPlot(History = history)

    Figure 7. Example of the use of the ExtinctionPlot function showing the accumulated secondary extinctions against number of extinctions

    -
    ExtinctionPlot(History = history, Variable = "LinksPerSpecies")
    +
    ExtinctionPlot(History = history, Variable = "LinksPerSpecies")

    Figure 8. Another example of the use of the ExtinctionPlot function showing the number of links per species against number of extinctions

    @@ -381,8 +381,8 @@

    Degree distribution function

    The degree_distribution function calculates the cumulative distribution of the number of links that each species in the food network has (Estrada 2007). Then, the observed distribution is fitted to the exponential and power law distribution models.

    The results of this function are shown in figure 9 and table 4. The graph shows the observed degree distribution in a log log scale fitting the three models mentioned above, for this example we use an example dataset of Chilean litoral rocky shores (Kéfi et al. 2015). The table shows the fitted model information ordered by descending AIC, that is, the model in the first row is the most probable distribution, followed by the second an finally the third distribution in this case (Table 3), the Exponential distribution would be the best model, followed by the Power law and finally the Truncated power law model.

    -
    data("chilean_intertidal")
    -degree_distribution(chilean_intertidal)
    +
    data("chilean_intertidal")
    +degree_distribution(chilean_intertidal)

    Figure 9: Fitted vs observed values of the degree distribution. The black line and points show the observed values, the red, green and blue lines show the fitted values for the Exponential, power law and trucated distribution, respectively

    NumExt
    @@ -420,71 +420,33 @@

    Bibliography

    -
    - -Albert, Réka, and Albert-László Barabási. 2002. “Statistical Mechanics -of Complex Networks.” *Reviews of Modern Physics* 74 (1). APS: 47. - +

    Albert, Réka, and Albert-László Barabási. 2002. “Statistical Mechanics of Complex Networks.” Reviews of Modern Physics 74 (1). APS: 47.

    -
    - -Dunne, Jennifer A, and Richard J Williams. 2009. “Cascading Extinctions -and Community Collapse in Model Food Webs.” *Philosophical Transactions -of the Royal Society B: Biological Sciences* 364 (1524). The Royal -Society: 1711–23. - +

    Dunne, Jennifer A, and Richard J Williams. 2009. “Cascading Extinctions and Community Collapse in Model Food Webs.” Philosophical Transactions of the Royal Society B: Biological Sciences 364 (1524). The Royal Society: 1711–23.

    -
    - -Dunne, Jennifer A, Richard J Williams, and Neo D Martinez. 2002. -“Food-Web Structure and Network Theory: The Role of Connectance and -Size.” *Proceedings of the National Academy of Sciences* 99 (20). -National Acad Sciences: 12917–22. - +

    Dunne, Jennifer A, Richard J Williams, and Neo D Martinez. 2002. “Food-Web Structure and Network Theory: The Role of Connectance and Size.” Proceedings of the National Academy of Sciences 99 (20). National Acad Sciences: 12917–22.

    -
    - -Estrada, Ernesto. 2007. “Food Webs Robustness to Biodiversity Loss: The -Roles of Connectance, Expansibility and Degree Distribution.” *Journal -of Theoretical Biology* 244 (2). Elsevier: 296–307. - +

    Estrada, Ernesto. 2007. “Food Webs Robustness to Biodiversity Loss: The Roles of Connectance, Expansibility and Degree Distribution.” Journal of Theoretical Biology 244 (2). Elsevier: 296–307.

    -
    - -Kéfi, Sonia, Eric L Berlow, Evie A Wieters, Lucas N Joppa, Spencer A -Wood, Ulrich Brose, and Sergio A Navarrete. 2015. “Network Structure -Beyond Food Webs: Mapping Non-Trophic and Trophic Interactions on -Chilean Rocky Shores.” *Ecology* 96 (1). Wiley Online Library: 291–303. - +

    Kéfi, Sonia, Eric L Berlow, Evie A Wieters, Lucas N Joppa, Spencer A Wood, Ulrich Brose, and Sergio A Navarrete. 2015. “Network Structure Beyond Food Webs: Mapping Non-Trophic and Trophic Interactions on Chilean Rocky Shores.” Ecology 96 (1). Wiley Online Library: 291–303.

    -
    - -Santana, Charles N de, Alejandro F Rozenfeld, Pablo A Marquet, and -Carlos M Duarte. 2013. “Topological Properties of Polar Food Webs.” -*Marine Ecology Progress Series* 474: 15–26. - +

    Santana, Charles N de, Alejandro F Rozenfeld, Pablo A Marquet, and Carlos M Duarte. 2013. “Topological Properties of Polar Food Webs.” Marine Ecology Progress Series 474: 15–26.

    -
    - -Sole, Ricard V, and M Montoya. 2001. “Complexity and Fragility in -Ecological Networks.” *Proceedings of the Royal Society of London B: -Biological Sciences* 268 (1480). The Royal Society: 2039–45. - +

    Sole, Ricard V, and M Montoya. 2001. “Complexity and Fragility in Ecological Networks.” Proceedings of the Royal Society of London B: Biological Sciences 268 (1480). The Royal Society: 2039–45.

    -
    -
    @@ -165,20 +168,12 @@

    Examp #> [1] 2 #> [1] 3 #> [1] 4
    ExtinctionPlot(History = history)
    # You can also specify the variable to be ploted in the y axis -ExtinctionPlot(History = history, Variable = "LinksPerSpecies")
    +ExtinctionPlot(History = history, Variable = "Link_density")
    - @@ -189,7 +184,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.1.

    diff --git a/docs/reference/Less_Connected.html b/docs/reference/Less_Connected.html index 704c39f..d65073d 100644 --- a/docs/reference/Less_Connected.html +++ b/docs/reference/Less_Connected.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -46,7 +50,6 @@ - @@ -64,7 +67,7 @@ - +
    - @@ -162,7 +162,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.1.

    diff --git a/docs/reference/More_Connected.html b/docs/reference/More_Connected.html index 3c5845f..56f8203 100644 --- a/docs/reference/More_Connected.html +++ b/docs/reference/More_Connected.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -46,7 +50,6 @@ - @@ -64,7 +67,7 @@ - +
    - @@ -162,7 +162,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.1.

    diff --git a/docs/reference/Mostconnected.html b/docs/reference/Mostconnected.html index 30e209e..1085a65 100644 --- a/docs/reference/Mostconnected.html +++ b/docs/reference/Mostconnected.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -51,7 +55,6 @@ in the previous step and recalculate which is the new most connected node and so on, until the number of links in the network is zero." /> - @@ -69,7 +72,7 @@ - +
    #> [1] 1 #> [1] 2 #> [1] 3 -#> [1] 4
    #> Spp nodesS linksS Conectance LinksPerSpecies Secondary_extinctions -#> 1 6 9 7 0.08641975 0.7777778 1 -#> 2 7 7 4 0.08163265 0.5714286 0 -#> 3 5 6 2 0.05555556 0.3333333 1 -#> 4 2 4 0 0.00000000 0.0000000 1 -#> Predation_release isolated_nodes AccSecondaryExtinction NumExt TotalExt -#> 1 0 1 1 1 2 -#> 2 2 2 1 2 3 -#> 3 3 3 2 3 5 -#> 4 3 4 3 4 7
    +#> [1] 4
    #> Spp S L C Link_density SecExt Pred_release Iso_nodes AccSecExt +#> 1 6 9 7 0.08641975 0.7777778 1 0 1 1 +#> 2 7 7 4 0.08163265 0.5714286 0 2 2 1 +#> 3 5 6 2 0.05555556 0.3333333 1 3 3 2 +#> 4 2 4 0 0.00000000 0.0000000 1 3 4 3 +#> NumExt TotalExt +#> 1 1 2 +#> 2 2 3 +#> 3 3 5 +#> 4 4 7
    - @@ -203,7 +198,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.1.

    diff --git a/docs/reference/RandomExtinctions-1.png b/docs/reference/RandomExtinctions-1.png index c1a1d3b..154a194 100644 Binary files a/docs/reference/RandomExtinctions-1.png and b/docs/reference/RandomExtinctions-1.png differ diff --git a/docs/reference/RandomExtinctions.html b/docs/reference/RandomExtinctions.html index 93fa2af..7677f03 100644 --- a/docs/reference/RandomExtinctions.html +++ b/docs/reference/RandomExtinctions.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -47,7 +51,6 @@ the mean and standard deviation of the accumulated secondary extinctions developed by making n random extinction histories" /> - @@ -65,7 +68,7 @@ - +
    #> 1
    #> 2
    #> 3
    #> 4
    #> 5
    #> 6
    #> 7
    #> 8
    #> 9
    #> 10
    #> 11
    #> 12
    #> 13
    #> 14
    #> 15
    #> 16
    #> 17
    #> 18
    #> 19
    #> 20
    #> Simulation 1 of 20 ready
    #> 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
    #> Simulation 2 of 20 ready
    #> 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
    #> Simulation 3 of 20 ready
    #> 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
    #> Warning: Coercing LHS to a list
    #> Simulation 4 of 20 ready
    #> 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
    #> Simulation 5 of 20 ready
    #> 1
    #> 2
    #> 3
    #> 4
    #> 5
    #> 6
    #> 7
    #> 8
    #> 9
    #> 10
    #> 11
    #> 12
    #> 13
    #> 14
    #> 15
    #> 16
    #> 17
    #> 18
    #> 19
    #> 20
    #> 21
    #> 22
    #> 23
    #> 24
    #> Warning: Coercing LHS to a list
    #> Simulation 6 of 20 ready
    #> 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
    #> Warning: Coercing LHS to a list
    #> Simulation 7 of 20 ready
    #> 1
    #> 2
    #> 3
    #> 4
    #> 5
    #> 6
    #> 7
    #> 8
    #> 9
    #> 10
    #> 11
    #> 12
    #> 13
    #> 14
    #> 15
    #> 16
    #> 17
    #> 18
    #> 19
    #> 20
    #> 21
    #> 22
    #> 23
    #> 24
    #> Simulation 8 of 20 ready
    #> 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
    #> Simulation 9 of 20 ready
    #> 1
    #> 2
    #> 3
    #> 4
    #> 5
    #> 6
    #> 7
    #> 8
    #> 9
    #> 10
    #> 11
    #> 12
    #> 13
    #> 14
    #> 15
    #> 16
    #> 17
    #> 18
    #> 19
    #> 20
    #> 21
    #> 22
    #> 23
    #> 24
    #> Warning: Density is not well-defined for networks of order 0.
    #> 25
    #> Simulation 10 of 20 ready
    #> 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
    #> Warning: Coercing LHS to a list
    #> Simulation 11 of 20 ready
    #> 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
    #> Warning: Density is not well-defined for networks of order 0.
    #> 27
    #> Simulation 12 of 20 ready
    #> 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
    #> Warning: Coercing LHS to a list
    #> Simulation 13 of 20 ready
    #> 1
    #> 2
    #> 3
    #> 4
    #> 5
    #> 6
    #> 7
    #> 8
    #> 9
    #> 10
    #> 11
    #> 12
    #> 13
    #> 14
    #> 15
    #> 16
    #> 17
    #> 18
    #> 19
    #> 20
    #> 21
    #> 22
    #> Simulation 14 of 20 ready
    #> 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
    #> Warning: Density is not well-defined for networks of order 0.
    #> 27
    #> Simulation 15 of 20 ready
    #> 1
    #> 2
    #> 3
    #> 4
    #> 5
    #> 6
    #> 7
    #> 8
    #> 9
    #> 10
    #> 11
    #> 12
    #> 13
    #> 14
    #> 15
    #> 16
    #> 17
    #> 18
    #> 19
    #> 20
    #> 21
    #> 22
    #> 23
    #> 24
    #> Simulation 16 of 20 ready
    #> 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
    #> Warning: Coercing LHS to a list
    #> Simulation 17 of 20 ready
    #> 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
    #> Warning: Coercing LHS to a list
    #> Simulation 18 of 20 ready
    #> 1
    #> 2
    #> 3
    #> 4
    #> 5
    #> 6
    #> 7
    #> 8
    #> 9
    #> 10
    #> 11
    #> 12
    #> 13
    #> 14
    #> 15
    #> 16
    #> 17
    #> 18
    #> 19
    #> 20
    #> 21
    #> 22
    #> Simulation 19 of 20 ready
    #> 1
    #> 2
    #> 3
    #> 4
    #> 5
    #> 6
    #> 7
    #> 8
    #> 9
    #> 10
    #> 11
    #> 12
    #> 13
    #> 14
    #> 15
    #> 16
    #> 17
    #> 18
    #> 19
    #> 20
    #> 21
    #> 22
    #> 23
    #> 24
    #> Simulation 20 of 20 ready
    #> $sims #> # A tibble: 29 x 3 -#> NumExt SdAccSecondaryExtinction AccSecondaryExtinction -#> <int> <dbl> <dbl> -#> 1 1 0.277 0.0769 -#> 2 2 0.555 0.154 -#> 3 3 0.877 0.462 -#> 4 4 1.09 0.769 -#> 5 5 1.66 1.46 -#> 6 6 1.58 2 -#> 7 7 1.81 2.54 -#> 8 8 1.98 2.62 -#> 9 9 2.33 3.08 -#> 10 10 2.43 3.38 +#> NumExt AccSecExt_sd AccSecExt_mean +#> <int> <dbl> <dbl> +#> 1 1 0.277 0.0769 +#> 2 2 0.555 0.154 +#> 3 3 0.877 0.462 +#> 4 4 1.09 0.769 +#> 5 5 1.66 1.46 +#> 6 6 1.58 2 +#> 7 7 1.81 2.54 +#> 8 8 1.98 2.62 +#> 9 9 2.33 3.08 +#> 10 10 2.43 3.38 #> # … with 19 more rows #> #> $graph
    #>
    - @@ -199,7 +195,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.1.

    diff --git a/docs/reference/chilean_intertidal.html b/docs/reference/chilean_intertidal.html index dc67de7..2000cde 100644 --- a/docs/reference/chilean_intertidal.html +++ b/docs/reference/chilean_intertidal.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -46,7 +50,6 @@ - @@ -64,7 +67,7 @@ - +
    - @@ -162,7 +162,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.1.

    diff --git a/docs/reference/degree_distribution-1.png b/docs/reference/degree_distribution-1.png index a067acb..cf84008 100644 Binary files a/docs/reference/degree_distribution-1.png and b/docs/reference/degree_distribution-1.png differ diff --git a/docs/reference/degree_distribution.html b/docs/reference/degree_distribution.html index 576b096..61b51b8 100644 --- a/docs/reference/degree_distribution.html +++ b/docs/reference/degree_distribution.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -49,7 +53,6 @@ the degree distribution in a log log scale showing the three fitted models mentioned above against the observed distribution." /> - @@ -67,7 +70,7 @@ - +
    #> Warning: Removed 5 rows containing missing values (geom_path).
    #> +#> $graph
    #> Warning: Removed 5 row(s) containing missing values (geom_path).
    #> #> $params #> # A tibble: 4 x 6 #> term estimate std.error statistic p.value model @@ -328,17 +331,10 @@

    Examp #>

    - @@ -349,7 +345,7 @@

    Author

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.1.

    diff --git a/docs/reference/index.html b/docs/reference/index.html index 43dcd69..e371f1d 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -44,7 +48,6 @@ - @@ -62,7 +65,7 @@ - +
    + +
    @@ -205,11 +213,10 @@

    -

    Contents

    -
    + @@ -220,7 +227,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.1.

    diff --git a/docs/reference/net.html b/docs/reference/net.html index 9d8ca0b..2591574 100644 --- a/docs/reference/net.html +++ b/docs/reference/net.html @@ -17,23 +17,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -45,7 +49,6 @@ - @@ -63,7 +66,7 @@ - +
    - @@ -156,7 +157,7 @@

    Contents

    -

    Site built with pkgdown 1.4.1.

    +

    Site built with pkgdown 1.5.1.

    diff --git a/man/ExtinctionPlot.Rd b/man/ExtinctionPlot.Rd index 5d609e4..091f33e 100644 --- a/man/ExtinctionPlot.Rd +++ b/man/ExtinctionPlot.Rd @@ -4,7 +4,7 @@ \alias{ExtinctionPlot} \title{Plots the extinctions history of a network} \usage{ -ExtinctionPlot(History, Variable = "AccSecondaryExtinction") +ExtinctionPlot(History, Variable = "AccSecExt") } \arguments{ \item{History}{a NetworkTopology object obtained from the Mostconnected function @@ -26,7 +26,7 @@ data("net") history <- Mostconnected(Network = net) ExtinctionPlot(History = history) # You can also specify the variable to be ploted in the y axis -ExtinctionPlot(History = history, Variable = "LinksPerSpecies") +ExtinctionPlot(History = history, Variable = "Link_density") } \seealso{ [NetworkExtintion::ExtinctionOrder()] diff --git a/man/Less_Connected.Rd b/man/Less_Connected.Rd index 1c285d1..d315905 100644 --- a/man/Less_Connected.Rd +++ b/man/Less_Connected.Rd @@ -4,7 +4,9 @@ \name{Less_Connected} \alias{Less_Connected} \title{A sparsely connected foodweb} -\format{a network} +\format{ +a network +} \usage{ Less_Connected } diff --git a/man/More_Connected.Rd b/man/More_Connected.Rd index b176976..333a550 100644 --- a/man/More_Connected.Rd +++ b/man/More_Connected.Rd @@ -4,7 +4,9 @@ \name{More_Connected} \alias{More_Connected} \title{A densely connected foodweb} -\format{a network} +\format{ +a network +} \usage{ More_Connected } diff --git a/man/chilean_intertidal.Rd b/man/chilean_intertidal.Rd index f682fe5..4838ba0 100644 --- a/man/chilean_intertidal.Rd +++ b/man/chilean_intertidal.Rd @@ -4,7 +4,9 @@ \name{chilean_intertidal} \alias{chilean_intertidal} \title{The foodweb of the intertidal zone in central chile} -\format{a network} +\format{ +a network +} \usage{ chilean_intertidal } diff --git a/man/net.Rd b/man/net.Rd index 638a3ea..0300ebe 100644 --- a/man/net.Rd +++ b/man/net.Rd @@ -4,7 +4,9 @@ \name{net} \alias{net} \title{A toymodel trophic network} -\format{a network} +\format{ +a network +} \usage{ net } diff --git a/vignettes/How_to_use_the_NetworkExtinction_Package.Rmd b/vignettes/How_to_use_the_NetworkExtinction_Package.Rmd index 18b8815..1b44b75 100644 --- a/vignettes/How_to_use_the_NetworkExtinction_Package.Rmd +++ b/vignettes/How_to_use_the_NetworkExtinction_Package.Rmd @@ -135,7 +135,7 @@ The result of this function is the dataframe shown in table 1. The first column ```{r, fig.cap="Figure 3. The graph shows the number of accumulated secondary extinctions that occur when removing species from the most to the least connected species"} data("net") history <- Mostconnected(Network = net) -ExtinctionPlot(History = history, Variable = "AccSecondaryExtinction") +ExtinctionPlot(History = history, Variable = "AccSecExt") ``` @@ -222,7 +222,7 @@ ExtinctionPlot(History = history) ``` ```{r, fig.cap= "Figure 8. Another example of the use of the ExtinctionPlot function showing the number of links per species against number of extinctions"} -ExtinctionPlot(History = history, Variable = "LinksPerSpecies") +ExtinctionPlot(History = history, Variable = "Link_density") ```