#' Biological Value Index grapher
#'
#' @description Creates a graph to graphicaly represent the score matrix of the Biological Value Index.
#'
#' @param bvi_scores An object of class data.frame generated generated by bvi()
#'
#' @seealso bvi
#'
#' @author Villasenor-Derbez, J.C.
#'
#' @export
#'
bvi_plot=function(bvi_scores){
library(ggplot2)
library(dplyr)
library(tidyr)
total=colSums(bvi_scores[2:(length(bvi_scores)-2)])
total=matrix(total, nrow=length(bvi_scores)-3, ncol=length(bvi_scores$spp))
bvi_scores[2:(length(bvi_scores)-2)]=bvi_scores[2:(length(bvi_scores)-2)]/total
bvi_scores=bvi_scores%>%
select(1:(length(bvi_scores)-2))%>%
gather(sample, score, -1)
ggplot(bvi_scores, aes(x=sample, y=score, fill=spp))+
geom_bar(stat="identity", color="black")+
scale_y_continuous(labels = scales::percent)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.