├── man ├── .Rapp.history ├── dmin.Rd ├── cor_dist.Rd ├── pipe.Rd ├── standardizeZScore.Rd ├── duffy_2003.Rd ├── relevantSp.Rd ├── qw.Rd ├── standardizeUnitScale.Rd ├── all_biodepth.Rd ├── whichVars.Rd ├── dmean.Rd ├── eff_num_func_d.Rd ├── eff_num_func_no_d.Rd ├── eff_num_func_d_onerow.Rd ├── getStdAndMeanFunctions.Rd ├── divNeeded.Rd ├── filterOverData.Rd ├── filterCoefData.Rd ├── stdEffects.Rd ├── getCoefTab.Rd ├── getIndices.Rd ├── getOverlapSummary.Rd ├── sAICfun.Rd ├── getOverlap.Rd ├── eff_num_func.Rd ├── getFuncsMaxed.Rd ├── getRedundancy.Rd ├── getMF_eff.Rd └── getFuncMaxed.Rd ├── docs ├── _config.yml ├── reference │ ├── Rplot001.png │ ├── getStdAndMeanFunctions-1.png │ ├── dmin.html │ ├── duffy_2003.html │ ├── pipe.html │ ├── cor_dist.html │ ├── standardizeZScore.html │ ├── all_biodepth.html │ ├── eff_div.html │ ├── relevantSp.html │ └── funcEven.html ├── articles │ ├── multifunc_eff_num_func_files │ │ └── figure-html │ │ │ ├── duffy-1.png │ │ │ ├── unnamed-chunk-2-1.png │ │ │ └── unnamed-chunk-4-1.png │ ├── multifunc_biodepth_files │ │ └── figure-html │ │ │ ├── unnamed-chunk-7-1.png │ │ │ ├── unnamed-chunk-12-1.png │ │ │ ├── unnamed-chunk-14-1.png │ │ │ ├── unnamed-chunk-15-1.png │ │ │ ├── unnamed-chunk-17-1.png │ │ │ ├── unnamed-chunk-18-1.png │ │ │ ├── unnamed-chunk-22-1.png │ │ │ ├── unnamed-chunk-23-1.png │ │ │ ├── unnamed-chunk-24-1.png │ │ │ ├── unnamed-chunk-26-1.png │ │ │ ├── unnamed-chunk-27-1.png │ │ │ └── unnamed-chunk-30-1.png │ └── index.html ├── pkgdown.yml ├── link.svg ├── bootstrap-toc.css ├── docsearch.js ├── sitemap.xml ├── pkgdown.js ├── LICENSE-text.html ├── bootstrap-toc.js ├── 404.html └── LICENSE.html ├── LICENSE ├── data ├── duffy_2003.rda └── all_biodepth.rda ├── R ├── globals.R ├── multifunc.R ├── utils-pipe.R ├── duffy_2003.R ├── standardizeZScore.R ├── qw.R ├── relevantSp.R ├── all_biodepth.R ├── StandardizeUnitScale.R ├── whichVars.R ├── getStdAndMeanFunctions.R ├── filterOverData.R ├── filterCoefData.R ├── divNeeded.R ├── stdEffects.R ├── getOverlapSummary.R ├── getFuncsMaxed.R ├── getOverlap.R ├── getCoefTab.R ├── sAICfun.R ├── getFuncMaxed.R ├── getIndices.R └── getRedundancy.R ├── cran-comments.md ├── .Rbuildignore ├── multifunc.Rproj ├── NAMESPACE ├── DESCRIPTION ├── LICENSE.md ├── README.md ├── NEWS.md ├── inst └── CITATION └── CODE_OF_CONDUCT.md /man/.Rapp.history: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2022 2 | COPYRIGHT HOLDER: Jarrett Byrnes 3 | -------------------------------------------------------------------------------- /data/duffy_2003.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/data/duffy_2003.rda -------------------------------------------------------------------------------- /data/all_biodepth.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/data/all_biodepth.rda -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /docs/reference/getStdAndMeanFunctions-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/reference/getStdAndMeanFunctions-1.png -------------------------------------------------------------------------------- /R/globals.R: -------------------------------------------------------------------------------- 1 | utils::globalVariables(c( 2 | "mod", 3 | "err", 4 | "err_conv", 5 | "coefs", 6 | "estimate", 7 | "p.value", 8 | "term", 9 | "funcMaxed" 10 | )) 11 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | * local OS X install, R 4.1.1 3 | * win-builder (devel and release) 4 | 5 | ## R CMD check results 6 | There were no ERRORs or WARNINGs. 7 | -------------------------------------------------------------------------------- /docs/articles/multifunc_eff_num_func_files/figure-html/duffy-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_eff_num_func_files/figure-html/duffy-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-15-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-15-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-18-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-18-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-22-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-22-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-23-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-23-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-24-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-24-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-26-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-26-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-27-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-27-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-30-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_biodepth_files/figure-html/unnamed-chunk-30-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_eff_num_func_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_eff_num_func_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /docs/articles/multifunc_eff_num_func_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jebyrnes/multifunc/HEAD/docs/articles/multifunc_eff_num_func_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^\.travis\.yml$ 2 | ^\.git$ 3 | ^\.gitignore$ 4 | ^.*\.Rproj$ 5 | ^.*\.Rhistory$ 6 | ^\.Rproj\.user$ 7 | docs 8 | ^cran-comments\.md$ 9 | ^LICENSE\.md$ 10 | ^CODE_OF_CONDUCT\.md$ 11 | ^CRAN-RELEASE$ 12 | -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: 2.17.1.1 2 | pkgdown: 2.0.2 3 | pkgdown_sha: ~ 4 | articles: 5 | multifunc_biodepth: multifunc_biodepth.html 6 | multifunc_eff_num_func: multifunc_eff_num_func.html 7 | last_built: 2022-05-19T21:08Z 8 | 9 | -------------------------------------------------------------------------------- /R/multifunc.R: -------------------------------------------------------------------------------- 1 | #' multifunc 2 | #' 3 | #' @name multifunc 4 | #' @docType package 5 | #' 6 | #' @description Methods for the analysis of how ecological drivers affect 7 | #' the multifunctionality of an ecosystem. 8 | #' @author Jarrett Byrnes 9 | #' NULL 10 | -------------------------------------------------------------------------------- /man/dmin.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/eff_num_func.R 3 | \name{dmin} 4 | \alias{dmin} 5 | \title{dmin} 6 | \usage{ 7 | dmin(D) 8 | } 9 | \arguments{ 10 | \item{D}{A distance matrix describing dissimilarity between functions.} 11 | } 12 | \value{ 13 | A numeric 14 | } 15 | \description{ 16 | Calculates the minimum non-zero value of a distance matrix 17 | } 18 | -------------------------------------------------------------------------------- /R/utils-pipe.R: -------------------------------------------------------------------------------- 1 | #' Pipe operator 2 | #' 3 | #' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. 4 | #' 5 | #' @name %>% 6 | #' @rdname pipe 7 | #' @keywords internal 8 | #' @export 9 | #' @importFrom magrittr %>% 10 | #' @usage lhs \%>\% rhs 11 | #' @param lhs A value or the magrittr placeholder. 12 | #' @param rhs A function call using the magrittr semantics. 13 | #' @return The result of calling `rhs(lhs)`. 14 | NULL 15 | -------------------------------------------------------------------------------- /multifunc.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | PackageRoxygenize: rd,collate,namespace 19 | -------------------------------------------------------------------------------- /man/cor_dist.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/eff_num_func.R 3 | \name{cor_dist} 4 | \alias{cor_dist} 5 | \title{cor_dist} 6 | \usage{ 7 | cor_dist(adf) 8 | } 9 | \arguments{ 10 | \item{adf}{A \code{data.frame} or \code{matrix} of functions} 11 | } 12 | \value{ 13 | A matrix 14 | } 15 | \description{ 16 | Takes a data frame of functions and calculates the correlation-based 17 | distance between functions. 18 | } 19 | -------------------------------------------------------------------------------- /R/duffy_2003.R: -------------------------------------------------------------------------------- 1 | #' @title Seagrass Mesocosm Data 2 | #' @description Data from the a seagrass grazer diversity manipulation at the Virginia Institute of Marine Sciences. From Duffy et al. 2003 Ecology Letters. 3 | #' 4 | #' @name duffy_2003 5 | #' @docType data 6 | #' @author Jarrett Byrnes 7 | #' @references Duffy, J. E., J. P. Richardson, and E. A. Canuel. 2003. Grazer diversity effects on ecosystem functioning in seagrass beds. Ecology letters 6:637-645. 8 | #' @keywords data 9 | NULL 10 | -------------------------------------------------------------------------------- /R/standardizeZScore.R: -------------------------------------------------------------------------------- 1 | #' @title standardizeZScore 2 | #' 3 | #' @description 4 | #' \code{standardizeZScore} Z-standardizes a vector. 5 | #' 6 | #' @details Centers a vector and divides it by its standard deviation. 7 | #' 8 | #' @author Jarrett Byrnes. 9 | #' @param afun A vector of measurements of a function. 10 | 11 | #' 12 | #' @export 13 | #' @return Returns a z-standardized vector. 14 | #' 15 | 16 | 17 | standardizeZScore <- function(afun) 18 | (afun - mean(afun, na.rm = FALSE)) / stats::sd(afun, na.rm = TRUE) 19 | -------------------------------------------------------------------------------- /man/pipe.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-pipe.R 3 | \name{\%>\%} 4 | \alias{\%>\%} 5 | \title{Pipe operator} 6 | \usage{ 7 | lhs \%>\% rhs 8 | } 9 | \arguments{ 10 | \item{lhs}{A value or the magrittr placeholder.} 11 | 12 | \item{rhs}{A function call using the magrittr semantics.} 13 | } 14 | \value{ 15 | The result of calling `rhs(lhs)`. 16 | } 17 | \description{ 18 | See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. 19 | } 20 | \keyword{internal} 21 | -------------------------------------------------------------------------------- /man/standardizeZScore.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/standardizeZScore.R 3 | \name{standardizeZScore} 4 | \alias{standardizeZScore} 5 | \title{standardizeZScore} 6 | \usage{ 7 | standardizeZScore(afun) 8 | } 9 | \arguments{ 10 | \item{afun}{A vector of measurements of a function.} 11 | } 12 | \value{ 13 | Returns a z-standardized vector. 14 | } 15 | \description{ 16 | \code{standardizeZScore} Z-standardizes a vector. 17 | } 18 | \details{ 19 | Centers a vector and divides it by its standard deviation. 20 | } 21 | \author{ 22 | Jarrett Byrnes. 23 | } 24 | -------------------------------------------------------------------------------- /man/duffy_2003.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/duffy_2003.R 3 | \docType{data} 4 | \name{duffy_2003} 5 | \alias{duffy_2003} 6 | \title{Seagrass Mesocosm Data} 7 | \description{ 8 | Data from the a seagrass grazer diversity manipulation at the Virginia Institute of Marine Sciences. From Duffy et al. 2003 Ecology Letters. 9 | } 10 | \references{ 11 | Duffy, J. E., J. P. Richardson, and E. A. Canuel. 2003. Grazer diversity effects on ecosystem functioning in seagrass beds. Ecology letters 6:637-645. 12 | } 13 | \author{ 14 | Jarrett Byrnes 15 | } 16 | \keyword{data} 17 | -------------------------------------------------------------------------------- /man/relevantSp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/relevantSp.R 3 | \name{relevantSp} 4 | \alias{relevantSp} 5 | \title{relevantSp} 6 | \usage{ 7 | relevantSp(data, colnums = 26:128) 8 | } 9 | \arguments{ 10 | \item{data}{A data frame with presence/abscence of different species.} 11 | 12 | \item{colnums}{Column numbers that will be assessed.} 13 | } 14 | \value{ 15 | A vector of columns names. 16 | } 17 | \description{ 18 | \code{relevantSp} Which species are being used in this analysis. 19 | } 20 | \details{ 21 | Which columns have values that are greater than zero. 22 | } 23 | \author{ 24 | Jarrett Byrnes. 25 | } 26 | -------------------------------------------------------------------------------- /R/qw.R: -------------------------------------------------------------------------------- 1 | #' @title Quote Words 2 | #' 3 | #' @description 4 | #' \code{qw} Takes an unquoted vector and adds quotes to it like the qw function in perl. 5 | #' 6 | #' @details This is a helper function for data processing. Honestly, I use qw all the time 7 | #' in other languages, and wanted a version for R. 8 | #' 9 | #' @author Jarrett Byrnes. 10 | #' @param ... Any unquoted strings 11 | #' 12 | #' 13 | #' @export 14 | #' @return A vector 15 | #' 16 | #' @examples 17 | #' c("a", "b") 18 | #' 19 | #' qw(a, b) 20 | #' 21 | #' 22 | #' 23 | #' # qw - a helper function that we 24 | #' # will use later to deal with strings 25 | #' # analagous to qw in PERL 26 | qw <- function(...) { 27 | sapply(match.call()[-1], deparse) 28 | } 29 | -------------------------------------------------------------------------------- /R/relevantSp.R: -------------------------------------------------------------------------------- 1 | #' @title relevantSp 2 | #' 3 | #' @description 4 | #' \code{relevantSp} Which species are being used in this analysis. 5 | #' 6 | #' @details Which columns have values that are greater than zero. 7 | #' 8 | #' @author Jarrett Byrnes. 9 | #' @param data A data frame with presence/abscence of different species. 10 | #' @param colnums Column numbers that will be assessed. 11 | #' 12 | #' @export 13 | #' @return A vector of columns names. 14 | #' 15 | 16 | 17 | # relevantSp takes a set of columns of species presence and abscence 18 | # and then examines which were actually included in an experiment 19 | # and returns their names 20 | relevantSp <- function(data, colnums = 26:128) { 21 | names(which(colSums(data[, colnums]) > 0)) 22 | } 23 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export("%>%") 4 | export(cor_dist) 5 | export(divNeeded) 6 | export(dmean) 7 | export(dmin) 8 | export(eff_num_func) 9 | export(eff_num_func_d) 10 | export(eff_num_func_d_onerow) 11 | export(eff_num_func_no_d) 12 | export(filterCoefData) 13 | export(filterOverData) 14 | export(getCoefTab) 15 | export(getFuncMaxed) 16 | export(getFuncsMaxed) 17 | export(getIndices) 18 | export(getMF_eff) 19 | export(getOverlap) 20 | export(getOverlapSummary) 21 | export(getRedundancy) 22 | export(getStdAndMeanFunctions) 23 | export(qw) 24 | export(relevantSp) 25 | export(sAICfun) 26 | export(standardizeUnitScale) 27 | export(standardizeZScore) 28 | export(stdEffects) 29 | export(whichVars) 30 | importFrom(magrittr,"%>%") 31 | -------------------------------------------------------------------------------- /man/qw.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/qw.R 3 | \name{qw} 4 | \alias{qw} 5 | \title{Quote Words} 6 | \usage{ 7 | qw(...) 8 | } 9 | \arguments{ 10 | \item{...}{Any unquoted strings} 11 | } 12 | \value{ 13 | A vector 14 | } 15 | \description{ 16 | \code{qw} Takes an unquoted vector and adds quotes to it like the qw function in perl. 17 | } 18 | \details{ 19 | This is a helper function for data processing. Honestly, I use qw all the time 20 | in other languages, and wanted a version for R. 21 | } 22 | \examples{ 23 | c("a", "b") 24 | 25 | qw(a, b) 26 | 27 | 28 | 29 | # qw - a helper function that we 30 | # will use later to deal with strings 31 | # analagous to qw in PERL 32 | } 33 | \author{ 34 | Jarrett Byrnes. 35 | } 36 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /man/standardizeUnitScale.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/StandardizeUnitScale.R 3 | \name{standardizeUnitScale} 4 | \alias{standardizeUnitScale} 5 | \title{standardizeUnitScale} 6 | \usage{ 7 | standardizeUnitScale(afun, min0 = TRUE, maxValue = max(afun, na.rm = T)) 8 | } 9 | \arguments{ 10 | \item{afun}{A vector of measurements of a function.} 11 | 12 | \item{min0}{Must a minimum value be greater than or equal to 0? Defaults to TRUE.} 13 | 14 | \item{maxValue}{The maximum valye by which the vector will be standardized. Defaults to 15 | the vector's maximum.} 16 | } 17 | \value{ 18 | Returns a standardized vector. 19 | } 20 | \description{ 21 | \code{standardizeUnitScale} standardized a variable so its maximum is 1 22 | } 23 | \details{ 24 | Takes a vector and then divides it by a maximum value. 25 | } 26 | \author{ 27 | Jarrett Byrnes. 28 | } 29 | -------------------------------------------------------------------------------- /R/all_biodepth.R: -------------------------------------------------------------------------------- 1 | #' @title Biodepth Data 2 | #' @description Data from the pan-European Biodepth grassland diversity manipulation 3 | #' 4 | #' @name all_biodepth 5 | #' @docType data 6 | #' @author Jarrett Byrnes 7 | #' @references Spehn, E. M., A. Hector, J. Joshi, M. Scherer-Lorenzen, B. Schmid, 8 | #' E. Bazeley-White, C. Beierkuhnlein, M. C. Caldeira, 9 | #' M. Diemer, P. G. Dimitrakopoulos, J. A. Finn, H. Freitas, P. S. Giller, 10 | #' J. Good, R. Harris, P. Hogberg, K. Huss-Danell, A. Jumpponen, J. Koricheva, 11 | #' P. W. Leadley, M. Loreau, A. Minns, C. P. H. Mulder, G. O'Donovan, S. J. Otway, 12 | #' C. Palmborg, J. S. Pereira, A. B. Pfisterer, A. Prinz, D. J. Read, E. D. Schulze, 13 | #' A. S. Siamantziouras, A. C. Terry, A. Y. Troumbis, F. I. Woodward, S. Yachi, and J. H. Lawton. 2005. 14 | #' Ecosystem effects of biodiversity manipulations in European grasslands. 15 | #' Ecological Monographs 75:37-63. 16 | #' @keywords data 17 | NULL 18 | -------------------------------------------------------------------------------- /man/all_biodepth.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/all_biodepth.R 3 | \docType{data} 4 | \name{all_biodepth} 5 | \alias{all_biodepth} 6 | \title{Biodepth Data} 7 | \description{ 8 | Data from the pan-European Biodepth grassland diversity manipulation 9 | } 10 | \references{ 11 | Spehn, E. M., A. Hector, J. Joshi, M. Scherer-Lorenzen, B. Schmid, 12 | E. Bazeley-White, C. Beierkuhnlein, M. C. Caldeira, 13 | M. Diemer, P. G. Dimitrakopoulos, J. A. Finn, H. Freitas, P. S. Giller, 14 | J. Good, R. Harris, P. Hogberg, K. Huss-Danell, A. Jumpponen, J. Koricheva, 15 | P. W. Leadley, M. Loreau, A. Minns, C. P. H. Mulder, G. O'Donovan, S. J. Otway, 16 | C. Palmborg, J. S. Pereira, A. B. Pfisterer, A. Prinz, D. J. Read, E. D. Schulze, 17 | A. S. Siamantziouras, A. C. Terry, A. Y. Troumbis, F. I. Woodward, S. Yachi, and J. H. Lawton. 2005. 18 | Ecosystem effects of biodiversity manipulations in European grasslands. 19 | Ecological Monographs 75:37-63. 20 | } 21 | \author{ 22 | Jarrett Byrnes 23 | } 24 | \keyword{data} 25 | -------------------------------------------------------------------------------- /man/whichVars.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/whichVars.R 3 | \name{whichVars} 4 | \alias{whichVars} 5 | \title{whichVars} 6 | \usage{ 7 | whichVars(a.df, vars = NA, thresh = 2/3) 8 | } 9 | \arguments{ 10 | \item{a.df}{A data frame} 11 | 12 | \item{vars}{The names of the columns that contain data of interest} 13 | 14 | \item{thresh}{The fraction of NA values in a column that is acceptable} 15 | } 16 | \value{ 17 | A vector of column names 18 | } 19 | \description{ 20 | \code{whichVars} takes a data frame and the names of a set of columns 21 | and returns the names of those columns that do not have an excessive fraction 22 | of NA values 23 | } 24 | \details{ 25 | This is a helper function for data processing. 26 | } 27 | \examples{ 28 | data(all_biodepth) 29 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 30 | 31 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 32 | 33 | vars <- whichVars(germany, allVars) 34 | } 35 | \author{ 36 | Jarrett Byrnes. 37 | } 38 | -------------------------------------------------------------------------------- /man/dmean.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/eff_num_func.R 3 | \name{dmean} 4 | \alias{dmean} 5 | \title{dmean} 6 | \usage{ 7 | dmean(adf_raw, D) 8 | } 9 | \arguments{ 10 | \item{adf_raw}{A data frame frame with functions in columns and rows as replicates} 11 | 12 | \item{D}{A distance matrix describing dissimilarity between functions.} 13 | } 14 | \value{ 15 | Single numeric of weighted average of distance matrix 16 | } 17 | \description{ 18 | Calculates the average distance between functions for one or an entire 19 | assemblage of replicates 20 | } 21 | \references{ 22 | Byrnes, J. E. K., Roger, F. and Bagchi, R. 2022. Understandable 23 | Multifunctionality Measures Using Hill Numbers. bioRxiv. 24 | 2022.03.17.484802. https://doi.org/10.1101/2022.03.17.484802 25 | 26 | Chao, A., Chiu, C.-H., Villéger, S., Sun, I.-F., Thorn, S., Lin, Y.-C., 27 | Chiang, J.-M. and Sherwin, W. B. 2019. An attribute-diversity approach to 28 | functional diversity, functional beta diversity, and related (dis)similarity 29 | measures. Ecological Monographs. 89: e01343. 30 | } 31 | -------------------------------------------------------------------------------- /R/StandardizeUnitScale.R: -------------------------------------------------------------------------------- 1 | #' @title standardizeUnitScale 2 | #' 3 | #' @description 4 | #' \code{standardizeUnitScale} standardized a variable so its maximum is 1 5 | #' 6 | #' @details Takes a vector and then divides it by a maximum value. 7 | #' 8 | #' @author Jarrett Byrnes. 9 | #' @param afun A vector of measurements of a function. 10 | #' @param min0 Must a minimum value be greater than or equal to 0? Defaults to TRUE. 11 | #' @param maxValue The maximum valye by which the vector will be standardized. Defaults to 12 | #' the vector's maximum. 13 | #' 14 | #' @export 15 | #' @return Returns a standardized vector. 16 | #' 17 | 18 | 19 | # standardizeFunction standardizes a function so that it's values are between 0 and 1 20 | # if the value of a function is <0, assumes that that is the lowest level possible 21 | standardizeUnitScale <- function(afun, min0 = TRUE, maxValue = max(afun, na.rm = TRUE)) { 22 | 23 | # add back minimum of negative values in function so you can rescale properly 24 | if (min0 && min(afun, na.rm = TRUE) < 0) afun <- afun + abs(min(afun, na.rm = TRUE)) 25 | 26 | afun / maxValue 27 | } 28 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: multifunc 2 | Version: 0.9.3 3 | Date: 2022-05-19 4 | Title: Analysis of Ecological Drivers on Ecosystem Multifunctionality 5 | Description: Methods for the analysis of how ecological drivers affect the 6 | multifunctionality of an ecosystem based on methods of Byrnes et al. 7 | 2016 and Byrnes et al. 8 | 2022 . Most standard 9 | methods in the literature are implemented (see vignettes) in a tidy 10 | format. 11 | Authors@R: person("Jarrett", "Byrnes", role = c("aut","cre", "cph"), email = "jarrett.byrnes@umb.edu") 12 | URL: https://jebyrnes.github.io/multifunc/, https://github.com/jebyrnes/multifunc 13 | BugReports: https://github.com/jebyrnes/multifunc/issues 14 | Imports: 15 | stats, 16 | dplyr, 17 | purrr, 18 | broom, 19 | MASS, 20 | utils, 21 | magrittr 22 | Suggests: 23 | ggplot2, 24 | forcats, 25 | tidyr, 26 | gridExtra, 27 | knitr, 28 | patchwork, 29 | car 30 | License: MIT + file LICENSE 31 | LazyData: true 32 | RoxygenNote: 7.1.1 33 | VignetteBuilder: knitr 34 | Encoding: UTF-8 35 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2022 Jarrett Byrnes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /R/whichVars.R: -------------------------------------------------------------------------------- 1 | #' @title whichVars 2 | #' 3 | #' @description 4 | #' \code{whichVars} takes a data frame and the names of a set of columns 5 | #' and returns the names of those columns that do not have an excessive fraction 6 | #' of NA values 7 | #' 8 | #' @details This is a helper function for data processing. 9 | #' 10 | #' @author Jarrett Byrnes. 11 | #' @param a.df A data frame 12 | #' @param vars The names of the columns that contain data of interest 13 | #' @param thresh The fraction of NA values in a column that is acceptable 14 | #' 15 | #' 16 | #' @export 17 | #' @return A vector of column names 18 | #' 19 | #' @examples 20 | #' data(all_biodepth) 21 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 22 | #' 23 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 24 | #' 25 | #' vars <- whichVars(germany, allVars) 26 | whichVars <- function(a.df, vars = NA, thresh = 2 / 3) { 27 | if (is.na(vars[1])) stop("No column names supplied.") 28 | tot <- nrow(a.df) 29 | 30 | # figure out which vars we can actually use 31 | usevar <- sapply(vars, function(x) sum(is.na(a.df[[x]])) / tot > thresh) 32 | vars <- vars[!usevar] 33 | 34 | vars 35 | } 36 | -------------------------------------------------------------------------------- /man/eff_num_func_d.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/eff_num_func.R 3 | \name{eff_num_func_d} 4 | \alias{eff_num_func_d} 5 | \title{eff_num_func_d} 6 | \usage{ 7 | eff_num_func_d(adf_freq, q = 1, D, tau = NULL) 8 | } 9 | \arguments{ 10 | \item{adf_freq}{A data frame of functional "frequencies" - i.e. f_i/sum(f_i)} 11 | 12 | \item{q}{Order of hill number used for index. Defaults to q=1, as in Shannon Diversity} 13 | 14 | \item{D}{A distance matrix describing dissimilarity between functions.} 15 | 16 | \item{tau}{A cutoff for degree of dissimilarity under which functions are considered 17 | to be different. If tau is the minimum non-zero value of D, all functions are different. 18 | if tau is the maximum value of D are greater, all functions are considered the same.} 19 | } 20 | \value{ 21 | A vector of effective number of functions 22 | } 23 | \description{ 24 | eff_num_func_d 25 | } 26 | \references{ 27 | Chao, A., Chiu, C.-H., Villéger, S., Sun, I.-F., Thorn, S., Lin, Y.-C., 28 | Chiang, J.-M. and Sherwin, W. B. 2019. An attribute-diversity approach to 29 | functional diversity, functional beta diversity, and related (dis)similarity 30 | measures. Ecological Monographs. 89: e01343. 31 | } 32 | -------------------------------------------------------------------------------- /man/eff_num_func_no_d.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/eff_num_func.R 3 | \name{eff_num_func_no_d} 4 | \alias{eff_num_func_no_d} 5 | \title{eff_num_func_no_d} 6 | \usage{ 7 | eff_num_func_no_d(adf_freq, q = 1) 8 | } 9 | \arguments{ 10 | \item{adf_freq}{A data frame of functional "frequencies" - i.e. f_i/sum(f_i)} 11 | 12 | \item{q}{Order of hill number used for index. Defaults to q=1, as in Shannon Diversity} 13 | } 14 | \value{ 15 | Returns a verctor of effective or standardized effective number of functions 16 | } 17 | \description{ 18 | eff_num_func_no_d 19 | } 20 | \details{ 21 | Takes a data frame, with functions standardized against total level of function 22 | in their replicate as columns and replicates as rows. Returns the effective number of functions using the appropriate method. See Chao 23 | et al. 2019 or Jost 2006 for details. Does not adjust for correlation between functions. 24 | } 25 | \references{ 26 | Chao, A., Chiu, C.-H., Villéger, S., Sun, I.-F., Thorn, S., Lin, Y.-C., 27 | Chiang, J.-M. and Sherwin, W. B. 2019. An attribute-diversity approach to 28 | functional diversity, functional beta diversity, and related (dis)similarity 29 | measures. Ecological Monographs. 89: e01343. 30 | 31 | Jost, L. 2006. Entropy and diversity. Oikos 113(2): 363-375. 32 | 33 | Hill, M. 1973. Diversity and evenness: A unifying notation and its 34 | consequences. Ecology 54: 427-432. 35 | } 36 | -------------------------------------------------------------------------------- /man/eff_num_func_d_onerow.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/eff_num_func.R 3 | \name{eff_num_func_d_onerow} 4 | \alias{eff_num_func_d_onerow} 5 | \title{eff_num_func_d_onerow} 6 | \usage{ 7 | eff_num_func_d_onerow(arow_freq, D, tau, q) 8 | } 9 | \arguments{ 10 | \item{arow_freq}{One replicate sample of different functions (a single numeric vector)} 11 | 12 | \item{D}{A distance matrix describing dissimilarity between functions.} 13 | 14 | \item{tau}{A cutoff for degree of dissimilarity under which functions are considered 15 | to be different. If tau is the minimum non-zero value of D, all functions are different. 16 | if tau is the maximum value of D are greater, all functions are considered the same.} 17 | 18 | \item{q}{Order of hill number used for index. Defaults to q=1, as in Shannon Diversity} 19 | } 20 | \value{ 21 | A single value of effective number of functions 22 | } 23 | \description{ 24 | eff_num_func_d_onerow 25 | } 26 | \references{ 27 | Byrnes, J. E. K., Roger, F. and Bagchi, R. 2022. Understandable 28 | Multifunctionality Measures Using Hill Numbers. bioRxiv. 29 | 2022.03.17.484802. https://doi.org/10.1101/2022.03.17.484802 30 | 31 | Chao, A., Chiu, C.-H., Villéger, S., Sun, I.-F., Thorn, S., Lin, Y.-C., 32 | Chiang, J.-M. and Sherwin, W. B. 2019. An attribute-diversity approach to 33 | functional diversity, functional beta diversity, and related (dis)similarity 34 | measures. Ecological Monographs. 89: e01343. 35 | } 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Analysis of the effects of drivers on multifunctionality within a system 2 | 3 | [![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable) 4 | [![CRAN status](https://www.r-pkg.org/badges/version/multifunc)](https://CRAN.R-project.org/package=multifunc) 5 | 6 | 7 | R package for the analysis of multifunctionality in ecological (or other) systems based on the following papers: 8 | 9 | Byrnes, J. E. K., Gamfeldt, L., Isbell, F., Lefcheck, J. S., Griffin, J. N., Hector, A., Cardinale, B. J., Hooper, D. U., Dee, L. E., Emmett Duffy, J. (2014), Investigating the relationship between biodiversity and ecosystem multifunctionality: challenges and solutions. Methods in Ecology and Evolution, 5: 111–124. doi: [10.1111/2041-210X.12143](http://dx.doi.org/10.1111/2041-210X.12143) 10 | 11 | Byrnes, J. E. K., Roger, F. and Bagchi, R. (2022), Understandable Multifunctionality Measures Using Hill Numbers. bioRxiv. 2022.03.17.484802. doi: [10.1101/2022.03.17.484802](https://doi.org/10.1101/2022.03.17.484802) 12 | 13 | library(devtools) 14 | install_github("jebyrnes/multifunc") 15 | 16 | For more, see http://jebyrnes.github.io/multifunc 17 | 18 | ## Contributions 19 | 20 | People wanting to contribute are welcome to do so by forking the repository, 21 | and submitting a pull request when their work is done. Please also edit the 22 | `DESCRIPTION` file to add your name to the `Authors` field. 23 | 24 | -------------------------------------------------------------------------------- /man/getStdAndMeanFunctions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/getStdAndMeanFunctions.R 3 | \name{getStdAndMeanFunctions} 4 | \alias{getStdAndMeanFunctions} 5 | \title{getStdAndMeanFunctions} 6 | \usage{ 7 | getStdAndMeanFunctions(data, vars, standardizeFunction = standardizeUnitScale) 8 | } 9 | \arguments{ 10 | \item{data}{A data frame with functions.} 11 | 12 | \item{vars}{The column names of the functions to be assessed.} 13 | 14 | \item{standardizeFunction}{A function to standardize each individual 15 | function to the same scale, such as \code{standardizeUnitScale} or 16 | \code{standardizeZScore}} 17 | } 18 | \value{ 19 | Returns a data frame with 20 | standardized values for each function and an averaged index. 21 | } 22 | \description{ 23 | \code{getStdAndMeanFunctions} creates an average function multifunctionality index. 24 | } 25 | \details{ 26 | iterates over all functions and 27 | standardizes them between 0 and 1. Then it creates an averaged 28 | multifunctionality index by averaging over all standardized functions 29 | } 30 | \examples{ 31 | data(all_biodepth) 32 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 33 | 34 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 35 | 36 | vars <- whichVars(germany, allVars) 37 | 38 | # re-normalize N.Soil so that everything is on the same 39 | # sign-scale (e.g. the maximum level of a function is 40 | # the "best" function) 41 | germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 42 | 43 | germany <- cbind(germany, getStdAndMeanFunctions(germany, vars)) 44 | } 45 | \author{ 46 | Jarrett Byrnes. 47 | } 48 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | ## multifunc 0.9.3 (Release date: 2022-05-19) 2 | * Minor revisions for CRAN 3 | * Includes link to bioRxiv paper 4 | 5 | ## multifunc 0.9.2 (Release date: 2022-04-16) 6 | * Cleanup for push to CRAN and paper submission to biorXiv 7 | 8 | ## multifunc 0.9.1 (Release date: 2022-02-14) 9 | * Added vignette for effective number of functions approach 10 | 11 | ## multifunc 0.9.0 (Release date: 2022-01-25) 12 | * Re-writing new metrics functions and changing names. 13 | * New functions from 0.8.0 are gone 14 | 15 | ## multifunc 0.8.0 (Release date: 2017-09-25) 16 | * Adding `getMF` and associated functions to incorporate ongoing work on new metrics 17 | * See also `funcEven` and `funcDiv` 18 | 19 | 20 | ## multifunc 0.7.3 (Release date: 2017-04-07) 21 | * Fixed `getCoefTab` to work better with categorical predictors 22 | * `getCoefTab` will now return all coefficients unless asked to filter to one 23 | 24 | 25 | ## multifunc 0.7.2 (Release date: 2017-03-17) 26 | * Fixed ASCII bug 27 | * Fixed and added vignette 28 | 29 | 30 | ## 0.7.1 (Release date: 2017-03-15) 31 | * Changed from Depends (from older version of R) to Imports 32 | * 33 | 34 | ## 0.6.2 (Release date: 2016-06-26) 35 | * Changed to semantic versioning. Added catch for users trying to get indices from multiple threshold approach when none of the coefficients of interest are different from 0. 36 | 37 | 38 | ## 0.6.1 (Release date 2016-03-25) 39 | * Fixed error in getMaxFuncs that was leading to one additional sample being pulled to calculate max values 40 | 41 | ## 0.6.0 (Release date 2013-11-18) 42 | * Fixed error in getMaxFuncs that was leading to bad row indices and no max being calculated 43 | 44 | ## 0.5.0 (Release Date 2013-02-11) 45 | * First release 46 | -------------------------------------------------------------------------------- /R/getStdAndMeanFunctions.R: -------------------------------------------------------------------------------- 1 | #' @title getStdAndMeanFunctions 2 | #' 3 | #' @description 4 | #' \code{getStdAndMeanFunctions} creates an average function multifunctionality index. 5 | #' 6 | #' @details iterates over all functions and 7 | #' standardizes them between 0 and 1. Then it creates an averaged 8 | #' multifunctionality index by averaging over all standardized functions 9 | #' 10 | #' @author Jarrett Byrnes. 11 | #' @param data A data frame with functions. 12 | #' @param vars The column names of the functions to be assessed. 13 | #' @param standardizeFunction A function to standardize each individual 14 | #' function to the same scale, such as \code{standardizeUnitScale} or 15 | #' \code{standardizeZScore} 16 | #' 17 | #' @export 18 | #' @return Returns a data frame with 19 | #' standardized values for each function and an averaged index. 20 | #' 21 | #' @examples 22 | #' data(all_biodepth) 23 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 24 | #' 25 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 26 | #' 27 | #' vars <- whichVars(germany, allVars) 28 | #' 29 | #' # re-normalize N.Soil so that everything is on the same 30 | #' # sign-scale (e.g. the maximum level of a function is 31 | #' # the "best" function) 32 | #' germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 33 | #' 34 | #' germany <- cbind(germany, getStdAndMeanFunctions(germany, vars)) 35 | getStdAndMeanFunctions <- function(data, vars, standardizeFunction = standardizeUnitScale) { 36 | ret <- dplyr::mutate(data, dplyr::across(vars, standardizeUnitScale, .names = "{.col}.std")) %>% 37 | dplyr::select(paste0(vars, ".std")) 38 | 39 | ret$meanFunction <- rowSums(ret) / ncol(ret) 40 | 41 | return(ret) 42 | } 43 | -------------------------------------------------------------------------------- /man/divNeeded.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/divNeeded.R 3 | \name{divNeeded} 4 | \alias{divNeeded} 5 | \title{divNeeded} 6 | \usage{ 7 | divNeeded(overData, type = "positive") 8 | } 9 | \arguments{ 10 | \item{overData}{Matrix of functions and which species affect them from \code{getRedundancy}.} 11 | 12 | \item{type}{Are the kinds of effects we're looking at "positive", "negative" or "all".} 13 | } 14 | \value{ 15 | Returns a data frame of all combinations and how many species are needed to 16 | influence all of them. 17 | } 18 | \description{ 19 | \code{divNeeded} Determines, for every combination of functions, how many species 20 | influence those functions. 21 | } 22 | \details{ 23 | Iterates over all possible combinations of functions. Checks the matrix of which species 24 | have positive, negative, or both influences on those functions. Tally's total number of species 25 | that have an effect on those functions 26 | } 27 | \examples{ 28 | data(all_biodepth) 29 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 30 | 31 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 32 | 33 | vars <- whichVars(germany, allVars) 34 | species <- relevantSp(germany, 26:ncol(germany)) 35 | 36 | # re-normalize N.Soil so that everything is on the 37 | # same sign-scale (e.g. the maximum level of a 38 | # function is the "best" function) 39 | germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 40 | 41 | res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 42 | names(res.list) <- vars 43 | 44 | redund <- getRedundancy(vars, species, germany) 45 | 46 | posCurve <- divNeeded(redund, type = "positive") 47 | } 48 | \author{ 49 | Jarrett Byrnes. 50 | } 51 | -------------------------------------------------------------------------------- /man/filterOverData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/filterOverData.R 3 | \name{filterOverData} 4 | \alias{filterOverData} 5 | \title{filterOverData} 6 | \usage{ 7 | filterOverData(overData, type = "positive") 8 | } 9 | \arguments{ 10 | \item{overData}{Matrix of functions and which species affect them from \code{getRedundancy}.} 11 | 12 | \item{type}{Are the kinds of effects we're looking at "positive", "negative" or "all".} 13 | } 14 | \value{ 15 | Returns a filtered matrix. 16 | } 17 | \description{ 18 | \code{filterOverData} filters qualitative effects of species 19 | to function by sign. 20 | } 21 | \details{ 22 | Takes a matrix of functions and effects 23 | of species - 1's and -1's, s - and filters out 24 | only the sign of contributions desired. Typically used by other functions in the package. 25 | } 26 | \examples{ 27 | data(all_biodepth) 28 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 29 | 30 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 31 | 32 | vars <- whichVars(germany, allVars) 33 | species <- relevantSp(germany, 26:ncol(germany)) 34 | 35 | # re-normalize N.Soil so that everything is on the same 36 | # sign-scale (e.g. the maximum level of a function is the 37 | # "best" function) 38 | germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 39 | 40 | res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 41 | names(res.list) <- vars 42 | 43 | redund <- getRedundancy(vars, species, germany) 44 | 45 | filterOverData(redund, type = "positive") 46 | 47 | 48 | ######### 49 | # filterOverData takes a matrix of 1s, 0s, and -1s 50 | # and filters it so that only the positive, negative, or both contributions 51 | # are 1 for later overlap function usage 52 | ######### 53 | } 54 | \author{ 55 | Jarrett Byrnes. 56 | } 57 | -------------------------------------------------------------------------------- /man/filterCoefData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/filterCoefData.R 3 | \name{filterCoefData} 4 | \alias{filterCoefData} 5 | \title{filterCoefData} 6 | \usage{ 7 | filterCoefData(coefData, type = "positive") 8 | } 9 | \arguments{ 10 | \item{coefData}{Matrix of functions and coefficients for which species affect them from \code{getRedundancy}.} 11 | 12 | \item{type}{Are the kinds of effects we're looking at "positive", "negative" or "all".} 13 | } 14 | \value{ 15 | Returns a filtered matrix. 16 | } 17 | \description{ 18 | \code{filterCoefData} filters contributions of species 19 | to function by sign. 20 | } 21 | \details{ 22 | Takes a matrix of functions and coefficients 23 | for species and filters out 24 | only the sign of contributions desired. Typically used by other functions in the package. 25 | } 26 | \examples{ 27 | data(all_biodepth) 28 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 29 | 30 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 31 | 32 | vars <- whichVars(germany, allVars) 33 | species <- relevantSp(germany, 26:ncol(germany)) 34 | 35 | # re-normalize N.Soil so that everything is on the same 36 | # sign-scale (e.g. the maximum level of a function is 37 | # the "best" function) 38 | germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 39 | 40 | res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 41 | names(res.list) <- vars 42 | 43 | coefs <- getRedundancy(vars, species, germany, output = "coef") 44 | stdCoefs <- stdEffects(coefs, germany, vars, species) 45 | 46 | filterCoefData(stdCoefs) 47 | 48 | 49 | ######### 50 | # filterCoefData takes a matrix of coefficients 51 | # and filters it so that only the positive, negative, or both contributions 52 | # are present 53 | ######### 54 | } 55 | \author{ 56 | Jarrett Byrnes. 57 | } 58 | -------------------------------------------------------------------------------- /man/stdEffects.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stdEffects.R 3 | \name{stdEffects} 4 | \alias{stdEffects} 5 | \title{stdEffects} 6 | \usage{ 7 | stdEffects(cmat, adf, vars, species) 8 | } 9 | \arguments{ 10 | \item{cmat}{Matrix of coefficients of species effects on functions from \code{getRedundancy} with output="coef".} 11 | 12 | \item{adf}{Data frame with plot level data for species and functions.} 13 | 14 | \item{vars}{Names of columns with data for functions in adf.} 15 | 16 | \item{species}{Names of columns with data for species in adf.} 17 | } 18 | \value{ 19 | Returns a matrix of standardized coefficients. 20 | } 21 | \description{ 22 | \code{stdEffects} obtains the standardized effect of each species on each function 23 | } 24 | \details{ 25 | stdEffects takes a matrix of coefficients for relationships 26 | between species and functions, the data frame used to generate those coefficients 27 | and the names of species and function, and then it calculates standardized coefficients 28 | using std coef = b *sx/sy 29 | } 30 | \examples{ 31 | data(all_biodepth) 32 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 33 | 34 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 35 | 36 | vars <- whichVars(germany, allVars) 37 | species <- relevantSp(germany, 26:ncol(germany)) 38 | 39 | # re-normalize N.Soil so that everything is on the same 40 | # sign-scale (e.g. the maximum level of a function is 41 | # the "best" function) 42 | germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 43 | 44 | res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 45 | names(res.list) <- vars 46 | 47 | coefs <- getRedundancy(vars, species, germany, output = "coef") 48 | stdCoefs <- stdEffects(coefs, germany, vars, species) 49 | 50 | ######### 51 | # A function that uses the coefficient matrix and information from the 52 | # data to calculate standardized effects of species using the method 53 | # std coef = b *sx/sy 54 | ######### 55 | } 56 | \author{ 57 | Jarrett Byrnes. 58 | } 59 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite multifunc in publications use:") 2 | 3 | citEntry(entry = "Article", 4 | title = "Investigating the relationship between biodiversity and ecosystem multifunctionality: challenges and solutions", 5 | author = personList(as.person("Jarrett E.K. Byrnes"), 6 | as.person("Lars Gamfeldt"), 7 | as.person("Forest Isbell"), 8 | as.person("Jonathan S. Lefcheck"), 9 | as.person("John N. Griffin"), 10 | as.person("Andy Hector"), 11 | as.person("Bradley J. Cardinale"), 12 | as.person("David U. Hooper"), 13 | as.person("Laura E. Dee") 14 | ), 15 | journal = "Methods in Ecology and Evolution", 16 | year = "2014", 17 | volume = "5", 18 | pages = "111--124", 19 | url = "https://doi.org/10.1111/2041-210X.12143", 20 | 21 | textVersion = 22 | paste("Byrnes, J. E. K., Gamfeldt, L., Isbell, F., Lefcheck, J. S.,", 23 | "Griffin, J. N., Hector, A., Cardinale, B. J., Hooper, D. U., Dee, L. E.", 24 | "and Emmett Duffy, J. 2014. Investigating the relationship between", 25 | "biodiversity and ecosystem multifunctionality: challenges and solutions.,", 26 | "Methods in Ecology and Evolution 5: 111–124. ", 27 | "https://doi.org/10.1111/2041-210X.12143" 28 | ) 29 | ) 30 | 31 | citEntry( 32 | entry = "Article", 33 | title = "Understandable Multifunctionality Measures Using Hill Numbers", 34 | author = personList(as.person("Jarrett E.K. Byrnes"), 35 | as.person("Fabian Roger"), 36 | as.person("Robert Bagchi")), 37 | journal = "bioRxiv", 38 | year = "2022", 39 | url = "https://doi.org/10.1101/2022.03.17.484802", 40 | textVersion = paste( 41 | "Byrnes, J. E. K., Roger, F. and Bagchi, R.", 42 | "2022. Understandable Multifunctionality Measures Using Hill", 43 | "Numbers. bioRxiv. 2022.03.17.484802. https://doi.org/10.1101/2022.03.17.484802" 44 | 45 | ) 46 | ) 47 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /R/filterOverData.R: -------------------------------------------------------------------------------- 1 | #' @title filterOverData 2 | #' 3 | #' @description 4 | #' \code{filterOverData} filters qualitative effects of species 5 | #' to function by sign. 6 | #' 7 | #' @details Takes a matrix of functions and effects 8 | #' of species - 1's and -1's, s - and filters out 9 | #' only the sign of contributions desired. Typically used by other functions in the package. 10 | #' 11 | #' @author Jarrett Byrnes. 12 | #' @param overData Matrix of functions and which species affect them from \code{getRedundancy}. 13 | #' @param type Are the kinds of effects we're looking at "positive", "negative" or "all". 14 | #' 15 | #' @export 16 | #' @return Returns a filtered matrix. 17 | #' 18 | #' @examples 19 | #' data(all_biodepth) 20 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 21 | #' 22 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 23 | #' 24 | #' vars <- whichVars(germany, allVars) 25 | #' species <- relevantSp(germany, 26:ncol(germany)) 26 | #' 27 | #' # re-normalize N.Soil so that everything is on the same 28 | #' # sign-scale (e.g. the maximum level of a function is the 29 | #' # "best" function) 30 | #' germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 31 | #' 32 | #' res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 33 | #' names(res.list) <- vars 34 | #' 35 | #' redund <- getRedundancy(vars, species, germany) 36 | #' 37 | #' filterOverData(redund, type = "positive") 38 | #' 39 | #' 40 | #' ######### 41 | #' # filterOverData takes a matrix of 1s, 0s, and -1s 42 | #' # and filters it so that only the positive, negative, or both contributions 43 | #' # are 1 for later overlap function usage 44 | #' ######### 45 | filterOverData <- function(overData, type = "positive") { 46 | # format the data properly given the type of analysis being done 47 | neg <- which(overData < 0, arr.ind = TRUE) 48 | pos <- which(overData > 0, arr.ind = TRUE) 49 | 50 | if (type == "positive" | type == "all") overData[neg] <- 0 51 | if (type == "negative") { 52 | overData[pos] <- 0 53 | overData[neg] <- 1 54 | } 55 | overData 56 | } 57 | -------------------------------------------------------------------------------- /man/getCoefTab.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/getCoefTab.R 3 | \name{getCoefTab} 4 | \alias{getCoefTab} 5 | \title{getCoefTab} 6 | \usage{ 7 | getCoefTab( 8 | eqn, 9 | fun = stats::glm, 10 | data, 11 | groupVar = "thresholds", 12 | coefVar = NULL, 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{eqn}{The model to be fit at each threshold.} 18 | 19 | \item{fun}{The fitting function. Defaults to \code{glm}.} 20 | 21 | \item{data}{A data frame containing the variables in the model to be fit.} 22 | 23 | \item{groupVar}{Grouping variable. Defaults to "thresholds" to fit the model at different 24 | thresholds, but, other types of grouping are possible.} 25 | 26 | \item{coefVar}{The name of the variable from the model whose coefficient we'll be extracting.} 27 | 28 | \item{...}{Other arguments to be supplied to the fitting function} 29 | } 30 | \value{ 31 | Returns a data frame of thresholds, coefficients, and their statistical properties. 32 | } 33 | \description{ 34 | \code{getCoefTab} extract the effect of diversity on number of functions greater than 35 | a threshold 36 | } 37 | \details{ 38 | getCoefTab Takes a statistical model and plot level data with the number of functions 39 | greater than a threshold at multiple different thresholds and returns the coefficient for the 40 | effect of diversity at each threshold 41 | } 42 | \examples{ 43 | \dontrun{ 44 | data(all_biodepth) 45 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 46 | 47 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 48 | 49 | vars <- whichVars(germany, allVars) 50 | 51 | # re-normalize N.Soil so that everything is on the same 52 | # sign-scale (e.g. the maximum level of a function is 53 | # the "best" function) 54 | germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 55 | 56 | germanyThresh <- getFuncsMaxed(germany, vars, 57 | threshmin = 0.05, 58 | threshmax = 0.99, prepend = c("plot", "Diversity"), maxN = 7 59 | ) 60 | 61 | germanyLinearSlopes <- getCoefTab(funcMaxed ~ Diversity, 62 | data = germanyThresh, coefVar = "Diversity", family = quasipoisson(link = "identity") 63 | ) 64 | 65 | } 66 | } 67 | \author{ 68 | Jarrett Byrnes. 69 | } 70 | -------------------------------------------------------------------------------- /R/filterCoefData.R: -------------------------------------------------------------------------------- 1 | #' @title filterCoefData 2 | #' @title filterCoefData 3 | #' 4 | #' @description 5 | #' \code{filterCoefData} filters contributions of species 6 | #' to function by sign. 7 | #' 8 | #' @details Takes a matrix of functions and coefficients 9 | #' for species and filters out 10 | #' only the sign of contributions desired. Typically used by other functions in the package. 11 | #' 12 | #' @author Jarrett Byrnes. 13 | #' @param coefData Matrix of functions and coefficients for which species affect them from \code{getRedundancy}. 14 | #' @param type Are the kinds of effects we're looking at "positive", "negative" or "all". 15 | #' 16 | #' @export 17 | #' @return Returns a filtered matrix. 18 | #' 19 | #' @examples 20 | #' data(all_biodepth) 21 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 22 | #' 23 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 24 | #' 25 | #' vars <- whichVars(germany, allVars) 26 | #' species <- relevantSp(germany, 26:ncol(germany)) 27 | #' 28 | #' # re-normalize N.Soil so that everything is on the same 29 | #' # sign-scale (e.g. the maximum level of a function is 30 | #' # the "best" function) 31 | #' germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 32 | #' 33 | #' res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 34 | #' names(res.list) <- vars 35 | #' 36 | #' coefs <- getRedundancy(vars, species, germany, output = "coef") 37 | #' stdCoefs <- stdEffects(coefs, germany, vars, species) 38 | #' 39 | #' filterCoefData(stdCoefs) 40 | #' 41 | #' 42 | #' ######### 43 | #' # filterCoefData takes a matrix of coefficients 44 | #' # and filters it so that only the positive, negative, or both contributions 45 | #' # are present 46 | #' ######### 47 | filterCoefData <- function(coefData, type = "positive") { 48 | # format the data properly given the type of analysis being done 49 | neg <- which(coefData < 0, arr.ind = TRUE) 50 | pos <- which(coefData > 0, arr.ind = TRUE) 51 | 52 | if (type == "positive") apply(neg, 1, function(x) coefData[x[1], x[2]] <<- 0) # ugh, using apply and <<- because nothing else worked 53 | if (type == "negative") { 54 | apply(pos, 1, function(x) coefData[x[1], x[2]] <<- 0) 55 | } 56 | # if(type=="all") apply(neg, 1, function(x) coefData[x[1], x[2]]<<-1) 57 | 58 | coefData 59 | } 60 | -------------------------------------------------------------------------------- /R/divNeeded.R: -------------------------------------------------------------------------------- 1 | #' @title divNeeded 2 | #' 3 | #' @description 4 | #' \code{divNeeded} Determines, for every combination of functions, how many species 5 | #' influence those functions. 6 | #' 7 | #' @details Iterates over all possible combinations of functions. Checks the matrix of which species 8 | #' have positive, negative, or both influences on those functions. Tally's total number of species 9 | #' that have an effect on those functions 10 | #' 11 | #' @author Jarrett Byrnes. 12 | #' @param overData Matrix of functions and which species affect them from \code{getRedundancy}. 13 | #' @param type Are the kinds of effects we're looking at "positive", "negative" or "all". 14 | #' 15 | #' 16 | #' @export 17 | #' @return Returns a data frame of all combinations and how many species are needed to 18 | #' influence all of them. 19 | #' 20 | #' @examples 21 | #' data(all_biodepth) 22 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 23 | #' 24 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 25 | #' 26 | #' vars <- whichVars(germany, allVars) 27 | #' species <- relevantSp(germany, 26:ncol(germany)) 28 | #' 29 | #' # re-normalize N.Soil so that everything is on the 30 | #' # same sign-scale (e.g. the maximum level of a 31 | #' # function is the "best" function) 32 | #' germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 33 | #' 34 | #' res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 35 | #' names(res.list) <- vars 36 | #' 37 | #' redund <- getRedundancy(vars, species, germany) 38 | #' 39 | #' posCurve <- divNeeded(redund, type = "positive") 40 | 41 | 42 | divNeeded <- function(overData, type = "positive") { 43 | overData <- filterOverData(overData, type = type) 44 | 45 | # go over all possible combinations of functions and see how many species are needed 46 | dn <- sapply(1:nrow(overData), function(m) { # sapply for num. of functions 47 | if (m == 1) { 48 | rowSums(overData) # species case if m=1 because combn borks on it 49 | } else { 50 | utils::combn(1:nrow(overData), m, function(x) length(which(colSums(overData[x, ]) > 0))) # combn to get each individual combo 51 | } 52 | }) 53 | 54 | ret <- data.frame(nfunc = 1, div = dn[[1]]) 55 | for (i in 2:length(dn)) ret <- rbind(ret, data.frame(nfunc = i, div = dn[[i]])) 56 | return(ret) 57 | } 58 | -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /man/getIndices.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/getIndices.R 3 | \name{getIndices} 4 | \alias{getIndices} 5 | \title{getIndices} 6 | \usage{ 7 | getIndices( 8 | slopedata, 9 | threshdata, 10 | eqn, 11 | fun = stats::glm, 12 | divvar = "Diversity", 13 | groupVar = "thresholds", 14 | showNfunc = T 15 | ) 16 | } 17 | \arguments{ 18 | \item{slopedata}{A data frame with slopes of the relationship between diversity and number of functions greather than or equal to a threshold 19 | from \code{getCoefTab}.} 20 | 21 | \item{threshdata}{A data frame with the number of functions greater than a threshold for each plot at each threshold from \code{getFuncsMaxed}.} 22 | 23 | \item{eqn}{The formula used for fitting the models in slopedata.} 24 | 25 | \item{fun}{The function used to refit the threshold data at key points to get intercepts, etc., that are needed for the table.} 26 | 27 | \item{divvar}{The name of the variable that has the measure of diversity or other driver in the threshdata data frame.} 28 | 29 | \item{groupVar}{The name of a variable by which data is grouped in the threshdata data frame. Typically "thresholds" from \code{getFuncsMaxed}.} 30 | 31 | \item{showNfunc}{Show the functions at Tmin, Tmax, and Tmde. Defaults to TRUE.} 32 | } 33 | \value{ 34 | A data frame of indices 35 | } 36 | \description{ 37 | \code{getIndices} Generates a variety of indices describing multifunctionality based on 38 | the number of functions greater than a threshold for many different threshold and coefficients describing 39 | the relationship between diversity and number of functoins greater than a threshold. 40 | } 41 | \details{ 42 | See Byrnes et al. In Review. 43 | } 44 | \examples{ 45 | \dontrun{ 46 | data(all_biodepth) 47 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 48 | 49 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 50 | 51 | vars <- whichVars(germany, allVars) 52 | 53 | germanyThresh <- getFuncsMaxed(germany, vars, 54 | threshmin = 0.05, 55 | threshmax = 0.99, prepend = c("plot", "Diversity"), maxN = 7 56 | ) 57 | 58 | germanyLinearSlopes <- getCoefTab(funcMaxed ~ Diversity, 59 | data = germanyThresh, 60 | coefVar = "Diversity", family = quasipoisson(link = "identity") 61 | ) 62 | 63 | getIndices(germanyLinearSlopes, germanyThresh, funcMaxed ~ Diversity) 64 | 65 | } 66 | } 67 | \author{ 68 | Jarrett Byrnes. 69 | } 70 | -------------------------------------------------------------------------------- /man/getOverlapSummary.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/getOverlapSummary.R 3 | \name{getOverlapSummary} 4 | \alias{getOverlapSummary} 5 | \title{getOverlapSummary} 6 | \usage{ 7 | getOverlapSummary( 8 | overData, 9 | m = 2, 10 | type = "positive", 11 | index = "sorensen", 12 | denom = "set" 13 | ) 14 | } 15 | \arguments{ 16 | \item{overData}{Matrix of functions and which species affect them from \code{getRedundancy}.} 17 | 18 | \item{m}{Number of functions. Defaults to 2.} 19 | 20 | \item{type}{Are the kinds of effects we're looking at "positive", "negative" or "all".} 21 | 22 | \item{index}{Type of overlap index to be used by \code{getOverlap}.} 23 | 24 | \item{denom}{Type of denominator to be used by \code{getOverlap}.} 25 | } 26 | \value{ 27 | Returns a data frame of the mean overlap, SD, and number of possible combinations. 28 | } 29 | \description{ 30 | \code{getOverlapSummary} summarizes the number of species necessary for each function 31 | including means, SDs, and other metrics 32 | } 33 | \details{ 34 | getOverlapSummary takes a matrix of 1s and -1s, and depending on whether we're 35 | interested in positive, negative, or both types of interactions looks for the 36 | m-wise overlap between species and then reports summary metrics of mean overlap, 37 | SD, and number of combinations 38 | } 39 | \examples{ 40 | data(all_biodepth) 41 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 42 | 43 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 44 | 45 | vars <- whichVars(germany, allVars) 46 | species <- relevantSp(germany, 26:ncol(germany)) 47 | 48 | # re-normalize N.Soil so that everything is on the same 49 | # sign-scale (e.g. the maximum level of a function is 50 | # the "best" function) 51 | germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 52 | 53 | res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 54 | names(res.list) <- vars 55 | 56 | redund <- getRedundancy(vars, species, germany) 57 | 58 | getOverlapSummary(redund, m = 2) 59 | 60 | 61 | ######### 62 | # getOverlapSummary takes a matrix of 1s and -1s, and depending on whether we're 63 | # interested in positive, negative, or both types of interactions looks for the 64 | # m-wise overlap and then reports summary metrics of mean overlap, SD, and number of combinations 65 | ######### 66 | } 67 | \author{ 68 | Jarrett Byrnes. 69 | } 70 | -------------------------------------------------------------------------------- /man/sAICfun.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sAICfun.R 3 | \name{sAICfun} 4 | \alias{sAICfun} 5 | \title{sAICfun} 6 | \usage{ 7 | sAICfun( 8 | response, 9 | species, 10 | data, 11 | positive.desired = TRUE, 12 | method = "lm", 13 | combine = "+", 14 | ... 15 | ) 16 | } 17 | \arguments{ 18 | \item{response}{Name of the response column} 19 | 20 | \item{species}{Vector of column names of species} 21 | 22 | \item{data}{data frame with species presence/abscence of values of functions} 23 | 24 | \item{positive.desired}{Is a positive effect the desired sign. Defaults to TRUE} 25 | 26 | \item{method}{Fitting function for statistical models. Defaults to \code{lm}.} 27 | 28 | \item{combine}{How are species combined in the model? Defaults to "+" for additive combinations.} 29 | 30 | \item{...}{Other arguments to be supplied to fitting function.} 31 | } 32 | \value{ 33 | Returns list of species with positive 34 | negative or neutral contributions, the 35 | relevant coefficient and effect matrices, and response name 36 | } 37 | \description{ 38 | \code{sAICfun} examines which species have an effect on which function using a stepwise AIC approach 39 | } 40 | \details{ 41 | \code{sAICfun} takes a dataset, response, and function, and then uses a stepAIC approach 42 | to determine the best model. From that it extracts the species with a positive, 43 | negative, and neutral effect on that function. 44 | } 45 | \examples{ 46 | data(all_biodepth) 47 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 48 | 49 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 50 | 51 | vars <- whichVars(germany, allVars) 52 | species <- relevantSp(germany, 26:ncol(germany)) 53 | 54 | # re-normalize N.Soil so that everything is on the same 55 | # sign-scale (e.g. the maximum level of a function is 56 | # the "best" function) 57 | germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 58 | 59 | spList <- sAICfun("biomassY3", species, germany) 60 | # " spList 61 | res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 62 | names(res.list) <- vars 63 | 64 | 65 | 66 | ######### 67 | # sAICfun takes a dataset, response, and function, and then uses a stepAIC approach 68 | # to determine the best model. From that it extracts the species with a positive, 69 | # negative, and neutral effect on that function 70 | ######### 71 | } 72 | \author{ 73 | Jarrett Byrnes. 74 | } 75 | -------------------------------------------------------------------------------- /R/stdEffects.R: -------------------------------------------------------------------------------- 1 | #' @title stdEffects 2 | #' 3 | #' @description 4 | #' \code{stdEffects} obtains the standardized effect of each species on each function 5 | #' 6 | #' @details stdEffects takes a matrix of coefficients for relationships 7 | #' between species and functions, the data frame used to generate those coefficients 8 | #' and the names of species and function, and then it calculates standardized coefficients 9 | #' using std coef = b *sx/sy 10 | #' 11 | #' @author Jarrett Byrnes. 12 | #' @param cmat Matrix of coefficients of species effects on functions from \code{getRedundancy} with output="coef". 13 | #' @param adf Data frame with plot level data for species and functions. 14 | #' @param vars Names of columns with data for functions in adf. 15 | #' @param species Names of columns with data for species in adf. 16 | #' 17 | #' 18 | #' @export 19 | #' @return Returns a matrix of standardized coefficients. 20 | #' 21 | #' @examples 22 | #' data(all_biodepth) 23 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 24 | #' 25 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 26 | #' 27 | #' vars <- whichVars(germany, allVars) 28 | #' species <- relevantSp(germany, 26:ncol(germany)) 29 | #' 30 | #' # re-normalize N.Soil so that everything is on the same 31 | #' # sign-scale (e.g. the maximum level of a function is 32 | #' # the "best" function) 33 | #' germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 34 | #' 35 | #' res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 36 | #' names(res.list) <- vars 37 | #' 38 | #' coefs <- getRedundancy(vars, species, germany, output = "coef") 39 | #' stdCoefs <- stdEffects(coefs, germany, vars, species) 40 | #' 41 | #' ######### 42 | #' # A function that uses the coefficient matrix and information from the 43 | #' # data to calculate standardized effects of species using the method 44 | #' # std coef = b *sx/sy 45 | #' ######### 46 | stdEffects <- function(cmat, adf, vars, species) { 47 | sFunc <- sapply(adf[, which(names(adf) %in% vars)], 48 | function(x) stats::sd(x, na.rm = TRUE)) 49 | sTrt <- sapply(adf[, which(names(adf) %in% species)], 50 | function(x) stats::sd(x, na.rm = TRUE)) 51 | sFunc_sTrt <- t(sTrt %*% t(1 / sFunc)) 52 | 53 | # get the order right 54 | sFunc_sTrt <- sFunc_sTrt[match(rownames(sFunc_sTrt), rownames(cmat)), ] 55 | 56 | # return the standardized coefs 57 | cmat[, -ncol(cmat)] * sFunc_sTrt 58 | } 59 | -------------------------------------------------------------------------------- /man/getOverlap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/getOverlap.R 3 | \name{getOverlap} 4 | \alias{getOverlap} 5 | \title{getOverlap} 6 | \usage{ 7 | getOverlap( 8 | overData, 9 | m = 2, 10 | type = "positive", 11 | index = "sorensen", 12 | denom = "set" 13 | ) 14 | } 15 | \arguments{ 16 | \item{overData}{Matrix of functions and which species affect them from \code{getRedundancy}.} 17 | 18 | \item{m}{Number of functions. Defaults to 2.} 19 | 20 | \item{type}{Are the kinds of effects we're looking at "positive", "negative" or "all".} 21 | 22 | \item{index}{Type of overlap index to be used. Defaults to "sorenson" but currently incorporates 23 | "mountford" and "jaccard" as well.} 24 | 25 | \item{denom}{Should the denominator be "all" species or just the "set" of species with the types 26 | of interactions being considered? Defaults to "set".} 27 | } 28 | \value{ 29 | Returns a vector of overlap indices. 30 | } 31 | \description{ 32 | \code{getOverlap} goes through all m-wise combinations of species 33 | and returns the amount of overlap between species in functions they perform 34 | for each combination 35 | } 36 | \details{ 37 | getOverlap takes a matrix of 1s and -1s, and depending on whether we're 38 | interested in positive, negative, or both types of interactions looks for the 39 | m-wise overlap between species and returns the overlap index for each combination 40 | } 41 | \examples{ 42 | data(all_biodepth) 43 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 44 | 45 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 46 | 47 | vars <- whichVars(germany, allVars) 48 | species <- relevantSp(germany, 26:ncol(germany)) 49 | 50 | # re-normalize N.Soil so that everything is on the 51 | # same sign-scale (e.g. the maximum level of a function is the "best" function) 52 | germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 53 | 54 | res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 55 | names(res.list) <- vars 56 | 57 | redund <- getRedundancy(vars, species, germany) 58 | 59 | getOverlap(redund, m = 2) 60 | getOverlap(redund, m = 2, index = "jaccard") 61 | getOverlap(redund, m = 2, index = "mountford") 62 | 63 | ######### 64 | # getOverlap takes a matrix of 1s and -1s, and depending on whether we're 65 | # interested in positive, negative, or both types of interactions looks for the 66 | # m-wise overlap 67 | ######### 68 | } 69 | \author{ 70 | Jarrett Byrnes. 71 | } 72 | -------------------------------------------------------------------------------- /man/eff_num_func.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/eff_num_func.R 3 | \name{eff_num_func} 4 | \alias{eff_num_func} 5 | \title{eff_num_func} 6 | \usage{ 7 | eff_num_func(dat, vars, q = 1, standardized = FALSE, D = NULL, tau = NULL) 8 | } 9 | \arguments{ 10 | \item{dat}{A data frame with functions in columns and rows as replicates as well as other information.} 11 | 12 | \item{vars}{Column names of function variables} 13 | 14 | \item{q}{Order of the diversity measure. Defaults to the 15 | Shannon case where q = 1. For Simpson, q=2.} 16 | 17 | \item{standardized}{Use standardized number of functions (scaled by total 18 | number of functions, so between 0-1), or just raw effective number of 19 | functions for calculation. Defaults to \code{FALSE}.} 20 | 21 | \item{D}{A distance matrix describing dissimilarity between functions. Defaults 22 | to NULL, and the index is calculated assuming all functions are different. If 23 | it is not null, it must be a symmetric matrix with dimensions matching the 24 | number of functions listed in \code{vars}.} 25 | 26 | \item{tau}{A cutoff for degree of dissimilarity under which functions are considered 27 | to be different. If tau is the minimum non-zero value of D, all functions are different. 28 | if tau is the maximum value of D are greater, all functions are considered the same.} 29 | } 30 | \value{ 31 | Returns a vector of effective or standardized effective number of functions 32 | } 33 | \description{ 34 | Calculate the effective number of functions for rows in a dataset 35 | } 36 | \details{ 37 | Takes a data frame, variable names, whether we want 38 | an index standardized by number of functions or not, an order of Hill number for our 39 | effective number of functions as well as a dissimilarity matrix (if desired) and value 40 | for a dissimilarity cutoff (defaults to the average dissimilarity). It then calculates 41 | and returns the effective number of functions using the appropriate method. See Chao 42 | et al. 2019 for more. 43 | } 44 | \references{ 45 | Chao, A., Chiu, C.-H., Villéger, S., Sun, I.-F., Thorn, S., Lin, Y.-C., 46 | Chiang, J.-M. and Sherwin, W. B. 2019. An attribute-diversity approach to 47 | functional diversity, functional beta diversity, and related (dis)similarity 48 | measures. Ecological Monographs. 89: e01343. 49 | 50 | Jost, L. 2006. Entropy and diversity. Oikos 113(2): 363-375. 51 | 52 | Hill, M. 1973. Diversity and evenness: A unifying notation and its 53 | consequences. Ecology 54: 427-432. 54 | } 55 | -------------------------------------------------------------------------------- /R/getOverlapSummary.R: -------------------------------------------------------------------------------- 1 | #' @title getOverlapSummary 2 | #' 3 | #' @description 4 | #' \code{getOverlapSummary} summarizes the number of species necessary for each function 5 | #' including means, SDs, and other metrics 6 | #' 7 | #' @details getOverlapSummary takes a matrix of 1s and -1s, and depending on whether we're 8 | #' interested in positive, negative, or both types of interactions looks for the 9 | #' m-wise overlap between species and then reports summary metrics of mean overlap, 10 | #' SD, and number of combinations 11 | #' 12 | #' @author Jarrett Byrnes. 13 | #' @param overData Matrix of functions and which species affect them from \code{getRedundancy}. 14 | #' @param m Number of functions. Defaults to 2. 15 | #' @param type Are the kinds of effects we're looking at "positive", "negative" or "all". 16 | #' @param index Type of overlap index to be used by \code{getOverlap}. 17 | #' @param denom Type of denominator to be used by \code{getOverlap}. 18 | #' 19 | #' 20 | #' @export 21 | #' @return Returns a data frame of the mean overlap, SD, and number of possible combinations. 22 | #' 23 | #' @examples 24 | #' data(all_biodepth) 25 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 26 | #' 27 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 28 | #' 29 | #' vars <- whichVars(germany, allVars) 30 | #' species <- relevantSp(germany, 26:ncol(germany)) 31 | #' 32 | #' # re-normalize N.Soil so that everything is on the same 33 | #' # sign-scale (e.g. the maximum level of a function is 34 | #' # the "best" function) 35 | #' germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 36 | #' 37 | #' res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 38 | #' names(res.list) <- vars 39 | #' 40 | #' redund <- getRedundancy(vars, species, germany) 41 | #' 42 | #' getOverlapSummary(redund, m = 2) 43 | #' 44 | #' 45 | #' ######### 46 | #' # getOverlapSummary takes a matrix of 1s and -1s, and depending on whether we're 47 | #' # interested in positive, negative, or both types of interactions looks for the 48 | #' # m-wise overlap and then reports summary metrics of mean overlap, SD, and number of combinations 49 | #' ######### 50 | getOverlapSummary <- function(overData, m = 2, type = "positive", index = "sorensen", denom = "set") { 51 | overlap <- getOverlap(overData, m = m, type = type, index = index, denom = denom) 52 | return(c( 53 | meanOverlap = mean(overlap), 54 | sdOverlap = stats::sd(overlap), 55 | n = length(overlap) 56 | )) 57 | } 58 | -------------------------------------------------------------------------------- /man/getFuncsMaxed.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/getFuncsMaxed.R 3 | \name{getFuncsMaxed} 4 | \alias{getFuncsMaxed} 5 | \title{getFuncsMaxed} 6 | \usage{ 7 | getFuncsMaxed( 8 | adf, 9 | vars = NA, 10 | threshmin = 0.05, 11 | threshmax = 0.99, 12 | threshstep = 0.01, 13 | proportion = FALSE, 14 | prepend = "Diversity", 15 | maxN = 1 16 | ) 17 | } 18 | \arguments{ 19 | \item{adf}{A data frame with functions.} 20 | 21 | \item{vars}{The column names of the functions to be assessed.} 22 | 23 | \item{threshmin}{The lowest threshold value to assess.} 24 | 25 | \item{threshmax}{The highest threshold value to assess} 26 | 27 | \item{threshstep}{The incremental steps between lowest and highest thresholds to be assessed. See \code{seq}.} 28 | 29 | \item{proportion}{Whether the output will be returned as a porportion of all functions. Defaults to \code{FALSE}.} 30 | 31 | \item{prepend}{Additional columns that will be imported from the data for the returned data frame.} 32 | 33 | \item{maxN}{As a 'maximum' value can be subject to outliers, etc., what number of the highest data points 34 | for a function will be used to calculate the value against which thresholds will be judged. E.g., if maxN=1 35 | then all thresholds are porportions of the largest value measured for a function. If maxN=8, then it's the 36 | porportion of the mean of the highest 8 measurements.} 37 | } 38 | \value{ 39 | Returns a data frame of number or fraction of functions greater than or equal to the selected thresholds in each plot over all thresholds within the relevant range. 40 | } 41 | \description{ 42 | \code{getFuncsMaxed} the number of functions greater than or equal to a wide variety of thresholds in each experimental unit 43 | } 44 | \details{ 45 | Create a data frame that has the value of number or proportion of functions 46 | greater than a threshold for several different thresholds at the plot. 47 | } 48 | \examples{ 49 | data(all_biodepth) 50 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 51 | 52 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 53 | 54 | vars <- whichVars(germany, allVars) 55 | 56 | # re-normalize N.Soil so that everything is on the same 57 | # sign-scale (e.g. the maximum level of a function is 58 | # the "best" function) 59 | germany$N.Soil <- -1 * germany$N.Soil + 60 | max(germany$N.Soil, na.rm = TRUE) 61 | 62 | germanyThresh <- getFuncsMaxed(germany, vars, 63 | threshmin = 0.50, 64 | threshmax = 0.60, prepend = c("plot", "Diversity"), maxN = 7 65 | ) 66 | 67 | 68 | } 69 | \author{ 70 | Jarrett Byrnes. 71 | } 72 | -------------------------------------------------------------------------------- /man/getRedundancy.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/getRedundancy.R 3 | \name{getRedundancy} 4 | \alias{getRedundancy} 5 | \title{getRedundancy} 6 | \usage{ 7 | getRedundancy( 8 | vars, 9 | species, 10 | data, 11 | negVars = NA, 12 | method = "lm", 13 | combine = "+", 14 | output = "effect", 15 | ... 16 | ) 17 | } 18 | \arguments{ 19 | \item{vars}{Vector of column names of functions} 20 | 21 | \item{species}{Vector of column names of species} 22 | 23 | \item{data}{data frame with species presence/absence of values of functions} 24 | 25 | \item{negVars}{Vector of names of species for which a negative coefficient is actually a positive effect.} 26 | 27 | \item{method}{Fitting function for statistical models. Defaults to \code{lm}.} 28 | 29 | \item{combine}{How are species combined in the model? Defaults to "+" for additive combinations.} 30 | 31 | \item{output}{Will the output be sign of effect or "coefficient". Defaults to "effect"} 32 | 33 | \item{...}{Other arguments to be supplied to fitting function.} 34 | } 35 | \value{ 36 | Returns a matrix of functions and the effect of species on each. 1s, -1s, and 0s for "effect" or coefficients. 37 | } 38 | \description{ 39 | \code{getRedundancy} examines which species have an effect on which function 40 | } 41 | \details{ 42 | getRedundancy takes a matrix of 1s,0s, and -1s, and depending on whether we're 43 | interested in positive, negative, or both types of interactions looks for the 44 | m-wise overlap between species and returns the overlap index for each combination. For 45 | species whose effect is not different from 0 at the alpha=0.05 level, a 0 is returned. 46 | } 47 | \examples{ 48 | data(all_biodepth) 49 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 50 | 51 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 52 | 53 | vars <- whichVars(germany, allVars) 54 | species <- relevantSp(germany, 26:ncol(germany)) 55 | 56 | # re-normalize N.Soil so that everything is on the same 57 | # sign-scale (e.g. the maximum level of a function is 58 | # the "best" function) 59 | germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 60 | 61 | res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 62 | names(res.list) <- vars 63 | 64 | getRedundancy(vars, species, germany) 65 | getRedundancy(vars, species, germany, output = "coef") 66 | 67 | 68 | 69 | ######### 70 | # takes a vector of responses, the species that may cause them 71 | # and returns a table of 1s, -1s, and 0s with regards to the kind of effect 72 | # or a coefficient table, if asked for. Arugments can take the form of the fitting function 73 | # how variables are combined, and additional arguments to the fitting function 74 | ######### 75 | } 76 | \author{ 77 | Jarrett Byrnes. 78 | } 79 | -------------------------------------------------------------------------------- /man/getMF_eff.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/eff_num_func.R 3 | \name{getMF_eff} 4 | \alias{getMF_eff} 5 | \title{getMF_eff} 6 | \usage{ 7 | getMF_eff( 8 | data, 9 | vars, 10 | q = 1, 11 | standardized = FALSE, 12 | standardize_function = standardizeUnitScale, 13 | D = NULL, 14 | tau = NULL 15 | ) 16 | } 17 | \arguments{ 18 | \item{data}{A data frame with functions in columns and rows as replicates as well as other information.} 19 | 20 | \item{vars}{Name of function variables} 21 | 22 | \item{q}{Order of the diversity measure. Defaults to the 23 | Shannon case where q = 1. For Simpson, q=2.} 24 | 25 | \item{standardized}{Use standardized number of functions (scaled by total 26 | number of functions, so between 0-1), or just raw effective number of 27 | functions for calculation. Defaults to \code{FALSE}.} 28 | 29 | \item{standardize_function}{A function to standardize each individual 30 | function to the same scale, such as \code{standardizeUnitScale} or 31 | \code{standardizeZScore}} 32 | 33 | \item{D}{A distance matrix describing dissimilarity between functions. Defaults 34 | to NULL, and the index is calculated assuming all functions are different. If 35 | it is not null, it must be a symmetric matrix with dimensions matching the 36 | number of functions listed in \code{vars}.} 37 | 38 | \item{tau}{A cutoff for degree of dissimilarity under which functions are considered 39 | to be different. If tau is the minimum non-zero value of D, all functions are different. 40 | if tau is the maximum value of D are greater, all functions are considered the same.} 41 | } 42 | \value{ 43 | Returns a vector of effective or standardized effective multifunctionality. 44 | } 45 | \description{ 46 | A multifunctionality index rooted in Hill numbers. 47 | \code{getMF_eff} get multifunctionality index defined by function and effective number of functions 48 | } 49 | \details{ 50 | Takes a data frame, variable names, a standardizing function, whether we want 51 | an index standardized by number of functions or not, an order of Hill number for our 52 | effective number of functions as well as a dissimilarity matrix (if desired) and value 53 | for a dissimilarity cutoff (defaults to the average dissimilarity). It then calculates 54 | both the average standardized function in each plot and the effective number of 55 | functions and returns their product as a measure of effective multifunctionality. 56 | } 57 | \references{ 58 | Chao, A., Chiu, C.-H., Villéger, S., Sun, I.-F., Thorn, S., Lin, Y.-C., 59 | Chiang, J.-M. and Sherwin, W. B. 2019. An attribute-diversity approach to 60 | functional diversity, functional beta diversity, and related (dis)similarity 61 | measures. Ecological Monographs. 89: e01343. 62 | 63 | Jost, L. 2006. Entropy and diversity. Oikos 113(2): 363-375. 64 | 65 | Hill, M. 1973. Diversity and evenness: A unifying notation and its 66 | consequences. Ecology 54: 427-432. 67 | } 68 | \author{ 69 | Jarrett Byrnes. 70 | } 71 | -------------------------------------------------------------------------------- /man/getFuncMaxed.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/getFuncMaxed.R 3 | \name{getFuncMaxed} 4 | \alias{getFuncMaxed} 5 | \title{getFuncMaxed} 6 | \usage{ 7 | getFuncMaxed( 8 | adf, 9 | vars = NA, 10 | thresh = 0.7, 11 | proportion = FALSE, 12 | prepend = "Diversity", 13 | maxN = 1 14 | ) 15 | } 16 | \arguments{ 17 | \item{adf}{A data frame with functions.} 18 | 19 | \item{vars}{The column names of the functions to be assessed.} 20 | 21 | \item{thresh}{The threshold value to assess.} 22 | 23 | \item{proportion}{Whether the output will be returned as a proportion of all functions. Defaults to \code{FALSE}.} 24 | 25 | \item{prepend}{Additional columns that will be imported from the data for the returned data frame.} 26 | 27 | \item{maxN}{As a 'maximum' value can be subject to outliers, etc., what number of the highest data points 28 | for a function will be used to calculate the value against which thresholds will be judged. E.g., if maxN=1 29 | then all thresholds are proportions of the largest value measured for a function. If maxN=8, then it's the 30 | proportion of the mean of the highest 8 measurements.} 31 | } 32 | \value{ 33 | Returns a data frame of number or fraction of functions greater than or equal to the selected thresholds in each plot. 34 | } 35 | \description{ 36 | \code{getFuncMaxed} the number of functions greater than or equal to a single threshold in one experimental unit 37 | } 38 | \details{ 39 | Create a data frame that has the value of number or proportion of functions 40 | greater than a single threshold. 41 | } 42 | \examples{ 43 | data(all_biodepth) 44 | allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 45 | 46 | germany <- subset(all_biodepth, all_biodepth$location == "Germany") 47 | 48 | vars <- whichVars(germany, allVars) 49 | 50 | # re-normalize N.Soil so that everything is on the same 51 | # sign-scale (e.g. the maximum level of a function is 52 | # the "best" function) 53 | germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 54 | 55 | germanyThresh <- getFuncMaxed(germany, vars, 56 | thresh = 0.5, 57 | prepend = c("plot", "Diversity"), 58 | maxN = 7) 59 | 60 | 61 | # A function that will return a data frame with the first several columns 62 | # being information the user wants for identification purposes (prepend) 63 | # which defaults to Diversity and the final column the number of columns 64 | # which pass a predefined threshold, defined as some proportion of the maximim 65 | # observed for each column. vars=the names of the vars being specified 66 | # thresh is the threshold, between 0 and 1, of proportion of the max that needs 67 | # to be passed to be counted. 68 | 69 | # changelog 70 | # 2014-03-24 Fixed -1 error in getMaxValue 71 | # 2015-06-24 Fixed column name from prepend error https://github.com/jebyrnes/multifunc/issues/1 72 | # 2022-04-14 Updated to use dplyr 73 | } 74 | \author{ 75 | Jarrett Byrnes. 76 | } 77 | -------------------------------------------------------------------------------- /R/getFuncsMaxed.R: -------------------------------------------------------------------------------- 1 | #' @title getFuncsMaxed 2 | #' 3 | #' @description 4 | #' \code{getFuncsMaxed} the number of functions greater than or equal to a wide variety of thresholds in each experimental unit 5 | #' 6 | #' @details Create a data frame that has the value of number or proportion of functions 7 | #' greater than a threshold for several different thresholds at the plot. 8 | #' 9 | #' @author Jarrett Byrnes. 10 | #' @param adf A data frame with functions. 11 | #' @param vars The column names of the functions to be assessed. 12 | #' @param threshmin The lowest threshold value to assess. 13 | #' @param threshmax The highest threshold value to assess 14 | #' @param threshstep The incremental steps between lowest and highest thresholds to be assessed. See \code{seq}. 15 | #' @param proportion Whether the output will be returned as a porportion of all functions. Defaults to \code{FALSE}. 16 | #' @param prepend Additional columns that will be imported from the data for the returned data frame. 17 | #' @param maxN As a 'maximum' value can be subject to outliers, etc., what number of the highest data points 18 | #' for a function will be used to calculate the value against which thresholds will be judged. E.g., if maxN=1 19 | #' then all thresholds are porportions of the largest value measured for a function. If maxN=8, then it's the 20 | #' porportion of the mean of the highest 8 measurements. 21 | #' 22 | #' 23 | #' @export 24 | #' @return Returns a data frame of number or fraction of functions greater than or equal to the selected thresholds in each plot over all thresholds within the relevant range. 25 | #' 26 | #' @examples 27 | #' data(all_biodepth) 28 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 29 | #' 30 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 31 | #' 32 | #' vars <- whichVars(germany, allVars) 33 | #' 34 | #' # re-normalize N.Soil so that everything is on the same 35 | #' # sign-scale (e.g. the maximum level of a function is 36 | #' # the "best" function) 37 | #' germany$N.Soil <- -1 * germany$N.Soil + 38 | #' max(germany$N.Soil, na.rm = TRUE) 39 | #' 40 | #' germanyThresh <- getFuncsMaxed(germany, vars, 41 | #' threshmin = 0.50, 42 | #' threshmax = 0.60, prepend = c("plot", "Diversity"), maxN = 7 43 | #' ) 44 | #' 45 | #' 46 | #### 47 | # Create a data frame that has the value of proportion of functions 48 | # greather than a threshold for several different thresholds at the plot 49 | # later 50 | #### 51 | getFuncsMaxed <- function(adf, vars = NA, 52 | threshmin = 0.05, threshmax = 0.99, 53 | threshstep = 0.01, proportion = FALSE, 54 | prepend = "Diversity", maxN = 1) { 55 | thresh_vec <- seq(threshmin, threshmax, threshstep) 56 | 57 | 58 | ret <- purrr::map_dfr( 59 | thresh_vec, 60 | ~ getFuncMaxed(adf, 61 | vars = vars, 62 | thresh = .x, # the threshold 63 | proportion = proportion, 64 | maxN = maxN, 65 | prepend = c(prepend) 66 | ) 67 | ) 68 | 69 | ret 70 | } 71 | -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /404.html 5 | 6 | 7 | /CODE_OF_CONDUCT.html 8 | 9 | 10 | /LICENSE-text.html 11 | 12 | 13 | /LICENSE.html 14 | 15 | 16 | /articles/index.html 17 | 18 | 19 | /articles/multifunc_biodepth.html 20 | 21 | 22 | /articles/multifunc_eff_num_func.html 23 | 24 | 25 | /authors.html 26 | 27 | 28 | /index.html 29 | 30 | 31 | /news/index.html 32 | 33 | 34 | /reference/all_biodepth.html 35 | 36 | 37 | /reference/cor_dist.html 38 | 39 | 40 | /reference/divNeeded.html 41 | 42 | 43 | /reference/dmean.html 44 | 45 | 46 | /reference/dmin.html 47 | 48 | 49 | /reference/duffy_2003.html 50 | 51 | 52 | /reference/eff_div.html 53 | 54 | 55 | /reference/eff_num_func.html 56 | 57 | 58 | /reference/eff_num_func_d.html 59 | 60 | 61 | /reference/eff_num_func_d_onerow.html 62 | 63 | 64 | /reference/eff_num_func_no_d.html 65 | 66 | 67 | /reference/filterCoefData.html 68 | 69 | 70 | /reference/filterOverData.html 71 | 72 | 73 | /reference/funcDiv.html 74 | 75 | 76 | /reference/funcEven.html 77 | 78 | 79 | /reference/getCoefTab.html 80 | 81 | 82 | /reference/getFuncMaxed.html 83 | 84 | 85 | /reference/getFuncsMaxed.html 86 | 87 | 88 | /reference/getIndices.html 89 | 90 | 91 | /reference/getMF.html 92 | 93 | 94 | /reference/getMF_eff.html 95 | 96 | 97 | /reference/getOverlap.html 98 | 99 | 100 | /reference/getOverlapSummary.html 101 | 102 | 103 | /reference/getRedundancy.html 104 | 105 | 106 | /reference/getStdAndMeanFunctions.html 107 | 108 | 109 | /reference/index.html 110 | 111 | 112 | /reference/pipe.html 113 | 114 | 115 | /reference/qw.html 116 | 117 | 118 | /reference/relevantSp.html 119 | 120 | 121 | /reference/sAICfun.html 122 | 123 | 124 | /reference/standardizeUnitScale.html 125 | 126 | 127 | /reference/standardizeZScore.html 128 | 129 | 130 | /reference/stdEffects.html 131 | 132 | 133 | /reference/whichVars.html 134 | 135 | 136 | -------------------------------------------------------------------------------- /R/getOverlap.R: -------------------------------------------------------------------------------- 1 | #' @title getOverlap 2 | #' 3 | #' @description 4 | #' \code{getOverlap} goes through all m-wise combinations of species 5 | #' and returns the amount of overlap between species in functions they perform 6 | #' for each combination 7 | #' 8 | #' @details getOverlap takes a matrix of 1s and -1s, and depending on whether we're 9 | #' interested in positive, negative, or both types of interactions looks for the 10 | #' m-wise overlap between species and returns the overlap index for each combination 11 | #' 12 | #' @author Jarrett Byrnes. 13 | #' @param overData Matrix of functions and which species affect them from \code{getRedundancy}. 14 | #' @param m Number of functions. Defaults to 2. 15 | #' @param type Are the kinds of effects we're looking at "positive", "negative" or "all". 16 | #' @param index Type of overlap index to be used. Defaults to "sorenson" but currently incorporates 17 | #' "mountford" and "jaccard" as well. 18 | #' @param denom Should the denominator be "all" species or just the "set" of species with the types 19 | #' of interactions being considered? Defaults to "set". 20 | #' 21 | #' 22 | #' @export 23 | #' @return Returns a vector of overlap indices. 24 | #' 25 | #' @examples 26 | #' data(all_biodepth) 27 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 28 | #' 29 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 30 | #' 31 | #' vars <- whichVars(germany, allVars) 32 | #' species <- relevantSp(germany, 26:ncol(germany)) 33 | #' 34 | #' # re-normalize N.Soil so that everything is on the 35 | #' # same sign-scale (e.g. the maximum level of a function is the "best" function) 36 | #' germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 37 | #' 38 | #' res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 39 | #' names(res.list) <- vars 40 | #' 41 | #' redund <- getRedundancy(vars, species, germany) 42 | #' 43 | #' getOverlap(redund, m = 2) 44 | #' getOverlap(redund, m = 2, index = "jaccard") 45 | #' getOverlap(redund, m = 2, index = "mountford") 46 | #' 47 | #' ######### 48 | #' # getOverlap takes a matrix of 1s and -1s, and depending on whether we're 49 | #' # interested in positive, negative, or both types of interactions looks for the 50 | #' # m-wise overlap 51 | #' ######### 52 | getOverlap <- function(overData, m = 2, type = "positive", index = "sorensen", denom = "set") { 53 | if (denom == "all") denomMat <- abs(overData) 54 | 55 | overData <- filterOverData(overData, type = type) 56 | 57 | if (denom != "all") denomMat <- overData 58 | 59 | overlap <- NA 60 | 61 | # jaccard of sorensen overlap? default is sorensen as it is what was used in Hector and Bagchi 62 | if (index == "jaccard" || index == "Jaccard") { 63 | overlap <- utils::combn(1:nrow(overData), m, function(x) length(which(colSums(overData[x, ]) == m)) / length(which(colSums(denomMat[x, ]) > 0))) 64 | } 65 | 66 | # from woulda 1981 Oecologia, mountford 1962 67 | if (index == "mountford" || index == "Mountford") { 68 | overlap <- utils::combn(1:nrow(overData), m, function(x) { 69 | j <- length(which(colSums(overData[x, ]) == m)) 70 | a_b <- sum(rowSums(denomMat[x, ])) 71 | ab <- prod(rowSums(denomMat[x, ])) 72 | overlap <- m * j / (2 * ab - a_b * j) 73 | }) 74 | } 75 | 76 | # non-ascii characters below, but foreign users may use the \u00f8 77 | if (index == "sorensen" || index == "Sorensen" || index == "s\u00F8rensen" || index == "S\u00F8rensen") { 78 | overlap <- utils::combn(1:nrow(overData), m, function(x) length(which(colSums(overData[x, ]) == m)) / (sum(rowSums(denomMat[x, ])) / m)) 79 | } 80 | 81 | if (is.na(overlap[1])) stop("Index should be jaccard, sorensen, or mountford") 82 | 83 | overlap 84 | } 85 | -------------------------------------------------------------------------------- /docs/pkgdown.js: -------------------------------------------------------------------------------- 1 | /* http://gregfranko.com/blog/jquery-best-practices/ */ 2 | (function($) { 3 | $(function() { 4 | 5 | $('.navbar-fixed-top').headroom(); 6 | 7 | $('body').css('padding-top', $('.navbar').height() + 10); 8 | $(window).resize(function(){ 9 | $('body').css('padding-top', $('.navbar').height() + 10); 10 | }); 11 | 12 | $('[data-toggle="tooltip"]').tooltip(); 13 | 14 | var cur_path = paths(location.pathname); 15 | var links = $("#navbar ul li a"); 16 | var max_length = -1; 17 | var pos = -1; 18 | for (var i = 0; i < links.length; i++) { 19 | if (links[i].getAttribute("href") === "#") 20 | continue; 21 | // Ignore external links 22 | if (links[i].host !== location.host) 23 | continue; 24 | 25 | var nav_path = paths(links[i].pathname); 26 | 27 | var length = prefix_length(nav_path, cur_path); 28 | if (length > max_length) { 29 | max_length = length; 30 | pos = i; 31 | } 32 | } 33 | 34 | // Add class to parent
  • , and enclosing
  • if in dropdown 35 | if (pos >= 0) { 36 | var menu_anchor = $(links[pos]); 37 | menu_anchor.parent().addClass("active"); 38 | menu_anchor.closest("li.dropdown").addClass("active"); 39 | } 40 | }); 41 | 42 | function paths(pathname) { 43 | var pieces = pathname.split("/"); 44 | pieces.shift(); // always starts with / 45 | 46 | var end = pieces[pieces.length - 1]; 47 | if (end === "index.html" || end === "") 48 | pieces.pop(); 49 | return(pieces); 50 | } 51 | 52 | // Returns -1 if not found 53 | function prefix_length(needle, haystack) { 54 | if (needle.length > haystack.length) 55 | return(-1); 56 | 57 | // Special case for length-0 haystack, since for loop won't run 58 | if (haystack.length === 0) { 59 | return(needle.length === 0 ? 0 : -1); 60 | } 61 | 62 | for (var i = 0; i < haystack.length; i++) { 63 | if (needle[i] != haystack[i]) 64 | return(i); 65 | } 66 | 67 | return(haystack.length); 68 | } 69 | 70 | /* Clipboard --------------------------*/ 71 | 72 | function changeTooltipMessage(element, msg) { 73 | var tooltipOriginalTitle=element.getAttribute('data-original-title'); 74 | element.setAttribute('data-original-title', msg); 75 | $(element).tooltip('show'); 76 | element.setAttribute('data-original-title', tooltipOriginalTitle); 77 | } 78 | 79 | if(ClipboardJS.isSupported()) { 80 | $(document).ready(function() { 81 | var copyButton = ""; 82 | 83 | $("div.sourceCode").addClass("hasCopyButton"); 84 | 85 | // Insert copy buttons: 86 | $(copyButton).prependTo(".hasCopyButton"); 87 | 88 | // Initialize tooltips: 89 | $('.btn-copy-ex').tooltip({container: 'body'}); 90 | 91 | // Initialize clipboard: 92 | var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { 93 | text: function(trigger) { 94 | return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); 95 | } 96 | }); 97 | 98 | clipboardBtnCopies.on('success', function(e) { 99 | changeTooltipMessage(e.trigger, 'Copied!'); 100 | e.clearSelection(); 101 | }); 102 | 103 | clipboardBtnCopies.on('error', function() { 104 | changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); 105 | }); 106 | }); 107 | } 108 | })(window.jQuery || window.$) 109 | -------------------------------------------------------------------------------- /R/getCoefTab.R: -------------------------------------------------------------------------------- 1 | #' @title getCoefTab 2 | #' 3 | #' @description 4 | #' \code{getCoefTab} extract the effect of diversity on number of functions greater than 5 | #' a threshold 6 | #' 7 | #' @details getCoefTab Takes a statistical model and plot level data with the number of functions 8 | #' greater than a threshold at multiple different thresholds and returns the coefficient for the 9 | #' effect of diversity at each threshold 10 | #' 11 | #' @author Jarrett Byrnes. 12 | #' @param eqn The model to be fit at each threshold. 13 | #' @param fun The fitting function. Defaults to \code{glm}. 14 | #' @param data A data frame containing the variables in the model to be fit. 15 | #' @param groupVar Grouping variable. Defaults to "thresholds" to fit the model at different 16 | #' thresholds, but, other types of grouping are possible. 17 | #' @param coefVar The name of the variable from the model whose coefficient we'll be extracting. 18 | #' @param ... Other arguments to be supplied to the fitting function 19 | #' 20 | #' 21 | #' @export 22 | #' @return Returns a data frame of thresholds, coefficients, and their statistical properties. 23 | #' 24 | #' @examples 25 | #'\donttest{ 26 | #' data(all_biodepth) 27 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 28 | #' 29 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 30 | #' 31 | #' vars <- whichVars(germany, allVars) 32 | #' 33 | #' # re-normalize N.Soil so that everything is on the same 34 | #' # sign-scale (e.g. the maximum level of a function is 35 | #' # the "best" function) 36 | #' germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 37 | #' 38 | #' germanyThresh <- getFuncsMaxed(germany, vars, 39 | #' threshmin = 0.05, 40 | #' threshmax = 0.99, prepend = c("plot", "Diversity"), maxN = 7 41 | #' ) 42 | #' 43 | #' germanyLinearSlopes <- getCoefTab(funcMaxed ~ Diversity, 44 | #' data = germanyThresh, coefVar = "Diversity", family = quasipoisson(link = "identity") 45 | #' ) 46 | #' 47 | #'} 48 | 49 | 50 | #### 51 | # A function that will take a data frame with a lot of different thresholds 52 | # and at each threshold, fit a user specified statistical model, then pull out 53 | # a coefficient of interest (e.g., Diversity) and it's information from a summar 54 | # table. This function can be used for glm and lm models, and potentially others 55 | # with the proper specification. 56 | ##### 57 | getCoefTab <- function(eqn, 58 | fun = stats::glm, 59 | data, 60 | groupVar = "thresholds", 61 | coefVar = NULL, ...) { 62 | 63 | 64 | get_model <- function(one_dat) { 65 | try(fun(eqn, data = one_dat, ...)) 66 | } 67 | 68 | ret <- data %>% 69 | dplyr::group_by(dplyr::across(groupVar)) %>% 70 | tidyr::nest() %>% 71 | dplyr::mutate(mod = purrr::map(data, get_model)) %>% 72 | # get info on if things failed 73 | dplyr::mutate( 74 | err = purrr::map_lgl(mod, ~ "try-error" %in% class(.x)), 75 | err_conv = purrr::map_lgl(mod, ~ ifelse("glm" %in% class(.x), 76 | !.x$converged, 77 | FALSE 78 | )), 79 | mod = ifelse(err + err_conv > 0, NA, mod) 80 | ) 81 | 82 | # get coefs 83 | ret <- ret %>% 84 | dplyr::mutate(coefs = purrr::map(mod, broom::tidy)) %>% 85 | dplyr::select(-data, -mod) %>% 86 | tidyr::unnest(coefs) %>% 87 | dplyr::ungroup() 88 | 89 | # filter out fit errors 90 | ret <- ret %>% 91 | dplyr::mutate(dplyr::across(estimate:p.value, ~ ifelse(err | err_conv, NA, .x))) %>% 92 | dplyr::select(-err, -err_conv) 93 | 94 | if (!is.null(coefVar)) { 95 | ret <- ret %>% dplyr::filter(term %in% coefVar) 96 | } 97 | 98 | 99 | return(ret) 100 | } 101 | -------------------------------------------------------------------------------- /R/sAICfun.R: -------------------------------------------------------------------------------- 1 | #' @title sAICfun 2 | #' 3 | #' @description 4 | #' \code{sAICfun} examines which species have an effect on which function using a stepwise AIC approach 5 | #' 6 | #' @details \code{sAICfun} takes a dataset, response, and function, and then uses a stepAIC approach 7 | #' to determine the best model. From that it extracts the species with a positive, 8 | #' negative, and neutral effect on that function. 9 | #' 10 | #' @author Jarrett Byrnes. 11 | #' @param response Name of the response column 12 | #' @param species Vector of column names of species 13 | #' @param data data frame with species presence/abscence of values of functions 14 | #' @param positive.desired Is a positive effect the desired sign. Defaults to TRUE 15 | #' @param method Fitting function for statistical models. Defaults to \code{lm}. 16 | #' @param combine How are species combined in the model? Defaults to "+" for additive combinations. 17 | #' @param ... Other arguments to be supplied to fitting function. 18 | #' 19 | #' 20 | #' @export 21 | #' @return Returns list of species with positive 22 | #' negative or neutral contributions, the 23 | #' relevant coefficient and effect matrices, and response name 24 | #' 25 | #' 26 | #' @examples 27 | #' data(all_biodepth) 28 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 29 | #' 30 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 31 | #' 32 | #' vars <- whichVars(germany, allVars) 33 | #' species <- relevantSp(germany, 26:ncol(germany)) 34 | #' 35 | #' # re-normalize N.Soil so that everything is on the same 36 | #' # sign-scale (e.g. the maximum level of a function is 37 | #' # the "best" function) 38 | #' germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 39 | #' 40 | #' spList <- sAICfun("biomassY3", species, germany) 41 | #' # " spList 42 | #' res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 43 | #' names(res.list) <- vars 44 | #' 45 | #' 46 | #' 47 | #' ######### 48 | #' # sAICfun takes a dataset, response, and function, and then uses a stepAIC approach 49 | #' # to determine the best model. From that it extracts the species with a positive, 50 | #' # negative, and neutral effect on that function 51 | #' ######### 52 | sAICfun <- function(response, species, data, positive.desired = TRUE, 53 | method = "lm", combine = "+", ...) { 54 | # first fit the model 55 | obj <- sAICFit(response, species, data, method, combine, ...) 56 | 57 | # now extract the important information about positive, negative, etc. 58 | 59 | # return that info in a list 60 | if (positive.desired) { 61 | pos.sp <- names(summary(obj)[[4]][, 4][(summary(obj)[[4]][, 1] > 0) & names(summary(obj)[[4]][, 4]) != "(Intercept)"]) 62 | neg.sp <- names(summary(obj)[[4]][, 4][(summary(obj)[[4]][, 1] < 0) & names(summary(obj)[[4]][, 4]) != "(Intercept)"]) 63 | } else { 64 | pos.sp <- names(summary(obj)[[4]][, 4][(summary(obj)[[4]][, 1] < 0) & names(summary(obj)[[4]][, 4]) != "(Intercept)"]) 65 | neg.sp <- names(summary(obj)[[4]][, 4][(summary(obj)[[4]][, 1] > 0) & names(summary(obj)[[4]][, 4]) != "(Intercept)"]) 66 | } 67 | neu.sp <- species[!(species %in% pos.sp) & !(species %in% neg.sp)] 68 | 69 | # make a vector of 1s and 0s 70 | effects <- rep(0, length(species)) 71 | names(effects) <- species 72 | effects[which(names(effects) %in% pos.sp)] <- 1 73 | effects[which(names(effects) %in% neg.sp)] <- -1 74 | 75 | coefs <- c(effects, 0) 76 | names(coefs)[length(coefs)] <- "(Intercept)" 77 | coefs[match(names(stats::coef(obj)), names(coefs))] <- stats::coef(obj) 78 | 79 | return(list(pos.sp = pos.sp, neg.sp = neg.sp, neu.sp = neu.sp, functions = response, coefs = coefs, effects = effects)) 80 | } 81 | 82 | ######### 83 | # sAICFit does the business of fitting a model using a stepAIC approach 84 | ######### 85 | sAICFit <- function(response, species, data, method = "lm", combine = "+", ...) { 86 | f <- stats::as.formula(paste(response, "~", paste(species, collapse = "+"))) 87 | fit <- eval(substitute(stats::lm(f, data = data, ...))) 88 | obj <- MASS::stepAIC(fit, trace = 0) 89 | obj 90 | } 91 | -------------------------------------------------------------------------------- /R/getFuncMaxed.R: -------------------------------------------------------------------------------- 1 | #' @title getFuncMaxed 2 | #' 3 | #' @description 4 | #' \code{getFuncMaxed} the number of functions greater than or equal to a single threshold in one experimental unit 5 | #' 6 | #' @details Create a data frame that has the value of number or proportion of functions 7 | #' greater than a single threshold. 8 | #' 9 | #' @author Jarrett Byrnes. 10 | #' @param adf A data frame with functions. 11 | #' @param vars The column names of the functions to be assessed. 12 | #' @param thresh The threshold value to assess. 13 | #' @param proportion Whether the output will be returned as a proportion of all functions. Defaults to \code{FALSE}. 14 | #' @param prepend Additional columns that will be imported from the data for the returned data frame. 15 | #' @param maxN As a 'maximum' value can be subject to outliers, etc., what number of the highest data points 16 | #' for a function will be used to calculate the value against which thresholds will be judged. E.g., if maxN=1 17 | #' then all thresholds are proportions of the largest value measured for a function. If maxN=8, then it's the 18 | #' proportion of the mean of the highest 8 measurements. 19 | #' 20 | #' @export 21 | #' @return Returns a data frame of number or fraction of functions greater than or equal to the selected thresholds in each plot. 22 | #' 23 | #' @examples 24 | #' data(all_biodepth) 25 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 26 | #' 27 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 28 | #' 29 | #' vars <- whichVars(germany, allVars) 30 | #' 31 | #' # re-normalize N.Soil so that everything is on the same 32 | #' # sign-scale (e.g. the maximum level of a function is 33 | #' # the "best" function) 34 | #' germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 35 | #' 36 | #' germanyThresh <- getFuncMaxed(germany, vars, 37 | #' thresh = 0.5, 38 | #' prepend = c("plot", "Diversity"), 39 | #' maxN = 7) 40 | #' 41 | #' 42 | #' # A function that will return a data frame with the first several columns 43 | #' # being information the user wants for identification purposes (prepend) 44 | #' # which defaults to Diversity and the final column the number of columns 45 | #' # which pass a predefined threshold, defined as some proportion of the maximim 46 | #' # observed for each column. vars=the names of the vars being specified 47 | #' # thresh is the threshold, between 0 and 1, of proportion of the max that needs 48 | #' # to be passed to be counted. 49 | #' 50 | #' # changelog 51 | #' # 2014-03-24 Fixed -1 error in getMaxValue 52 | #' # 2015-06-24 Fixed column name from prepend error https://github.com/jebyrnes/multifunc/issues/1 53 | #' # 2022-04-14 Updated to use dplyr 54 | getFuncMaxed <- function(adf, vars = NA, thresh = 0.7, proportion = FALSE, 55 | prepend = "Diversity", maxN = 1) { 56 | if (is.na(vars)[1]) stop("You need to specify some response variable names") 57 | 58 | # which are the relevant variables 59 | vars <- whichVars(adf, vars) 60 | 61 | # scan across all functions, see which are >= a threshold 62 | # funcMaxed<-rowSums(colwise(function(x) x >= (thresh*max(x, na.rm = TRUE)))(adf[,which(names(adf)%in%vars)])) 63 | getMaxValue <- function(x) { 64 | l <- length(x) 65 | mean(sort(x, na.last = FALSE)[l:(l - maxN + 1)], na.rm = TRUE) 66 | } 67 | 68 | # old 69 | # funcMaxed <- rowSums(colwise(function(x) x >= thresh*getMaxValue(x))(adf[,which(names(adf)%in%vars)])) 70 | 71 | ret <- adf %>% 72 | # get functions over threshold 73 | dplyr::mutate( 74 | thresholds = thresh, 75 | dplyr::across(vars, 76 | ~ .x >= thresh * max(.x, na.rm = TRUE), 77 | .names = "{.col}_OVER_THRESH" 78 | ), 79 | nFunc = length(vars) 80 | ) %>% 81 | # sum over functions 82 | dplyr::rowwise() %>% 83 | dplyr::mutate( 84 | funcMaxed = sum(dplyr::c_across(paste0(vars, "_OVER_THRESH"))) 85 | ) %>% 86 | dplyr::ungroup() %>% 87 | # cleanup 88 | dplyr::select(-dplyr::contains("_OVER_THRESH")) 89 | 90 | if (proportion) { 91 | ret <- ret %>% dplyr::mutate(funcMaxed = funcMaxed / length(vars)) 92 | } 93 | 94 | ret 95 | } 96 | -------------------------------------------------------------------------------- /R/getIndices.R: -------------------------------------------------------------------------------- 1 | #' @title getIndices 2 | #' 3 | #' @description 4 | #' \code{getIndices} Generates a variety of indices describing multifunctionality based on 5 | #' the number of functions greater than a threshold for many different threshold and coefficients describing 6 | #' the relationship between diversity and number of functoins greater than a threshold. 7 | #' 8 | #' @details See Byrnes et al. In Review. 9 | #' 10 | #' @author Jarrett Byrnes. 11 | #' @param slopedata A data frame with slopes of the relationship between diversity and number of functions greather than or equal to a threshold 12 | #' from \code{getCoefTab}. 13 | #' @param threshdata A data frame with the number of functions greater than a threshold for each plot at each threshold from \code{getFuncsMaxed}. 14 | #' @param eqn The formula used for fitting the models in slopedata. 15 | #' @param fun The function used to refit the threshold data at key points to get intercepts, etc., that are needed for the table. 16 | #' @param divvar The name of the variable that has the measure of diversity or other driver in the threshdata data frame. 17 | #' @param groupVar The name of a variable by which data is grouped in the threshdata data frame. Typically "thresholds" from \code{getFuncsMaxed}. 18 | #' @param showNfunc Show the functions at Tmin, Tmax, and Tmde. Defaults to TRUE. 19 | #' 20 | #' 21 | #' @export 22 | #' @return A data frame of indices 23 | #' 24 | #' @examples 25 | #'\donttest{ 26 | #' data(all_biodepth) 27 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 28 | #' 29 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 30 | #' 31 | #' vars <- whichVars(germany, allVars) 32 | #' 33 | #' germanyThresh <- getFuncsMaxed(germany, vars, 34 | #' threshmin = 0.05, 35 | #' threshmax = 0.99, prepend = c("plot", "Diversity"), maxN = 7 36 | #' ) 37 | #' 38 | #' germanyLinearSlopes <- getCoefTab(funcMaxed ~ Diversity, 39 | #' data = germanyThresh, 40 | #' coefVar = "Diversity", family = quasipoisson(link = "identity") 41 | #' ) 42 | #' 43 | #' getIndices(germanyLinearSlopes, germanyThresh, funcMaxed ~ Diversity) 44 | #' 45 | #' } 46 | getIndices <- function(slopedata, threshdata, eqn, fun = stats::glm, 47 | divvar = "Diversity", groupVar = "thresholds", 48 | showNfunc = TRUE) { 49 | Smax <- max(threshdata[[divvar]], na.rm = TRUE) 50 | Smin <- min(threshdata[[divvar]], na.rm = TRUE) 51 | tdata <- get_t_indices(slopedata) 52 | 53 | predFun <- function(thresh, S) { 54 | if (is.na(thresh)) { 55 | return(NA) 56 | } 57 | subdata <- threshdata[which(threshdata[[groupVar]] == thresh), ] 58 | fit <- getFit(eqn, fun, subdata) 59 | stats::predict(fit, newdata = subdata[which(threshdata[[divvar]] == S), ], type = "response")[1] 60 | } 61 | 62 | Mmin <- predFun(tdata$Tmin, Smax) 63 | Mmax <- predFun(tdata$Tmax, Smax) 64 | Mmde <- predFun(tdata$Tmde, Smax) 65 | Rmde.linear <- slopedata$estimate[which(slopedata[[groupVar]] == tdata$Tmde)] 66 | Pmde.linear <- slopedata$estimate[which(slopedata[[groupVar]] == tdata$Tmde)] / (threshdata$nFunc[1] / Smax) 67 | nFunc <- threshdata$nFunc[1] 68 | 69 | if (is.na(tdata$Tmde)) { 70 | warning("None of these coefficients are different from 0, hence indices have little meaning") 71 | Rmde.linear <- NA 72 | Pmde.linear <- NA 73 | } 74 | 75 | return(data.frame( 76 | Tmin = tdata$Tmin, 77 | Tmax = tdata$Tmax, 78 | Tmde = tdata$Tmde, 79 | Rmde.linear = Rmde.linear, 80 | Pmde.linear = Pmde.linear, 81 | Mmin = Mmin, 82 | Mmax = Mmax, 83 | Mmde = Mmde, 84 | nFunc = nFunc 85 | )) 86 | } 87 | 88 | 89 | getFit <- function(eqn, fun = stats::glm, adf, ...) { 90 | aFit <- try(fun(eqn, data = adf, ...)) 91 | 92 | # if there was a problem, catch it and just return NAs for this coefficient 93 | if ("try-error" %in% class(aFit)) { 94 | return(NA) 95 | } 96 | 97 | if ("glm" %in% class(aFit)) { 98 | if (!aFit$converged) { 99 | return(NA) 100 | } 101 | } 102 | 103 | return(aFit) 104 | } 105 | 106 | 107 | getIndices_nothresh <- function(eqn, fun = stats::glm, threshdata, divvar = "Diversity", groupVar = "thresholds", coefVar, ...) { 108 | slopedata <- getCoefTab(eqn, fun = fun, threshdata, groupVar = "thresholds", coefVar, ...) 109 | getIndices(slopedata, threshdata, eqn, fun, divvar, groupVar) 110 | } 111 | 112 | 113 | 114 | get_t_indices <- function(adf) { 115 | minSlope <- adf$estimate - 2 * adf[["std.error"]] 116 | maxSlope <- adf$estimate + 2 * adf[["std.error"]] 117 | sloperng <- rbind(minSlope, maxSlope) 118 | 119 | # which thresholds have non-zero slopes 120 | not0 <- sort(c(which(colSums(sloperng > 0) == 2), which(colSums(sloperng > 0) == 0))) 121 | 122 | if (length(not0) != 0) { 123 | if (not0[1] - 1 == 0) { 124 | Tmin <- NA 125 | } else { 126 | Tmin <- adf$thresholds[not0[1] - 1] 127 | } 128 | 129 | if (range(not0)[2] + 1 > length(adf$thresholds)) { 130 | Tmax <- NA 131 | } else { 132 | Tmax <- adf$thresholds[range(not0)[2] + 1] 133 | } 134 | } else { 135 | Tmin <- NA 136 | Tmax <- NA 137 | } 138 | 139 | Tmde <- adf$thresholds[which(adf$estimate == max(abs(adf$estimate), na.rm = TRUE))][1] # the [1] is in case there are multiple identical peaks 140 | return(data.frame(Tmin = Tmin, Tmax = Tmax, Tmde = Tmde)) 141 | } 142 | -------------------------------------------------------------------------------- /docs/LICENSE-text.html: -------------------------------------------------------------------------------- 1 | 2 | License • multifunc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 61 | 62 |
    YEAR: 2022
    63 | COPYRIGHT HOLDER: Jarrett Byrnes
    64 | 
    65 | 66 |
    67 | 68 | 71 | 72 |
    73 | 74 | 75 | 76 |
    79 | 80 |
    81 |

    Site built with pkgdown 82 | 2.0.2.

    83 |
    84 | 85 |
    86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /docs/bootstrap-toc.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | (function() { 6 | 'use strict'; 7 | 8 | window.Toc = { 9 | helpers: { 10 | // return all matching elements in the set, or their descendants 11 | findOrFilter: function($el, selector) { 12 | // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ 13 | // http://stackoverflow.com/a/12731439/358804 14 | var $descendants = $el.find(selector); 15 | return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); 16 | }, 17 | 18 | generateUniqueIdBase: function(el) { 19 | var text = $(el).text(); 20 | var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); 21 | return anchor || el.tagName.toLowerCase(); 22 | }, 23 | 24 | generateUniqueId: function(el) { 25 | var anchorBase = this.generateUniqueIdBase(el); 26 | for (var i = 0; ; i++) { 27 | var anchor = anchorBase; 28 | if (i > 0) { 29 | // add suffix 30 | anchor += '-' + i; 31 | } 32 | // check if ID already exists 33 | if (!document.getElementById(anchor)) { 34 | return anchor; 35 | } 36 | } 37 | }, 38 | 39 | generateAnchor: function(el) { 40 | if (el.id) { 41 | return el.id; 42 | } else { 43 | var anchor = this.generateUniqueId(el); 44 | el.id = anchor; 45 | return anchor; 46 | } 47 | }, 48 | 49 | createNavList: function() { 50 | return $(''); 51 | }, 52 | 53 | createChildNavList: function($parent) { 54 | var $childList = this.createNavList(); 55 | $parent.append($childList); 56 | return $childList; 57 | }, 58 | 59 | generateNavEl: function(anchor, text) { 60 | var $a = $(''); 61 | $a.attr('href', '#' + anchor); 62 | $a.text(text); 63 | var $li = $('
  • '); 64 | $li.append($a); 65 | return $li; 66 | }, 67 | 68 | generateNavItem: function(headingEl) { 69 | var anchor = this.generateAnchor(headingEl); 70 | var $heading = $(headingEl); 71 | var text = $heading.data('toc-text') || $heading.text(); 72 | return this.generateNavEl(anchor, text); 73 | }, 74 | 75 | // Find the first heading level (`

    `, then `

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

    `). 76 | getTopLevel: function($scope) { 77 | for (var i = 1; i <= 6; i++) { 78 | var $headings = this.findOrFilter($scope, 'h' + i); 79 | if ($headings.length > 1) { 80 | return i; 81 | } 82 | } 83 | 84 | return 1; 85 | }, 86 | 87 | // returns the elements for the top level, and the next below it 88 | getHeadings: function($scope, topLevel) { 89 | var topSelector = 'h' + topLevel; 90 | 91 | var secondaryLevel = topLevel + 1; 92 | var secondarySelector = 'h' + secondaryLevel; 93 | 94 | return this.findOrFilter($scope, topSelector + ',' + secondarySelector); 95 | }, 96 | 97 | getNavLevel: function(el) { 98 | return parseInt(el.tagName.charAt(1), 10); 99 | }, 100 | 101 | populateNav: function($topContext, topLevel, $headings) { 102 | var $context = $topContext; 103 | var $prevNav; 104 | 105 | var helpers = this; 106 | $headings.each(function(i, el) { 107 | var $newNav = helpers.generateNavItem(el); 108 | var navLevel = helpers.getNavLevel(el); 109 | 110 | // determine the proper $context 111 | if (navLevel === topLevel) { 112 | // use top level 113 | $context = $topContext; 114 | } else if ($prevNav && $context === $topContext) { 115 | // create a new level of the tree and switch to it 116 | $context = helpers.createChildNavList($prevNav); 117 | } // else use the current $context 118 | 119 | $context.append($newNav); 120 | 121 | $prevNav = $newNav; 122 | }); 123 | }, 124 | 125 | parseOps: function(arg) { 126 | var opts; 127 | if (arg.jquery) { 128 | opts = { 129 | $nav: arg 130 | }; 131 | } else { 132 | opts = arg; 133 | } 134 | opts.$scope = opts.$scope || $(document.body); 135 | return opts; 136 | } 137 | }, 138 | 139 | // accepts a jQuery object, or an options object 140 | init: function(opts) { 141 | opts = this.helpers.parseOps(opts); 142 | 143 | // ensure that the data attribute is in place for styling 144 | opts.$nav.attr('data-toggle', 'toc'); 145 | 146 | var $topContext = this.helpers.createChildNavList(opts.$nav); 147 | var topLevel = this.helpers.getTopLevel(opts.$scope); 148 | var $headings = this.helpers.getHeadings(opts.$scope, topLevel); 149 | this.helpers.populateNav($topContext, topLevel, $headings); 150 | } 151 | }; 152 | 153 | $(function() { 154 | $('nav[data-toggle="toc"]').each(function(i, el) { 155 | var $nav = $(el); 156 | Toc.init($nav); 157 | }); 158 | }); 159 | })(); 160 | -------------------------------------------------------------------------------- /docs/articles/index.html: -------------------------------------------------------------------------------- 1 | 2 | Articles • multifunc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 61 | 62 | 71 |
    72 |
    73 | 74 | 75 |
    78 | 79 |
    80 |

    Site built with pkgdown 81 | 2.0.2.

    82 |
    83 | 84 |
    85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /R/getRedundancy.R: -------------------------------------------------------------------------------- 1 | #' @title getRedundancy 2 | #' 3 | #' @description 4 | #' \code{getRedundancy} examines which species have an effect on which function 5 | #' 6 | #' @details getRedundancy takes a matrix of 1s,0s, and -1s, and depending on whether we're 7 | #' interested in positive, negative, or both types of interactions looks for the 8 | #' m-wise overlap between species and returns the overlap index for each combination. For 9 | #' species whose effect is not different from 0 at the alpha=0.05 level, a 0 is returned. 10 | #' 11 | #' @author Jarrett Byrnes. 12 | #' @param vars Vector of column names of functions 13 | #' @param species Vector of column names of species 14 | #' @param data data frame with species presence/absence of values of functions 15 | #' @param negVars Vector of names of species for which a negative coefficient is actually a positive effect. 16 | #' @param method Fitting function for statistical models. Defaults to \code{lm}. 17 | #' @param combine How are species combined in the model? Defaults to "+" for additive combinations. 18 | #' @param output Will the output be sign of effect or "coefficient". Defaults to "effect" 19 | #' @param ... Other arguments to be supplied to fitting function. 20 | #' 21 | #' 22 | #' @export 23 | #' @return Returns a matrix of functions and the effect of species on each. 1s, -1s, and 0s for "effect" or coefficients. 24 | #' 25 | #' 26 | #' @examples 27 | #' data(all_biodepth) 28 | #' allVars <- qw(biomassY3, root3, N.g.m2, light3, N.Soil, wood3, cotton3) 29 | #' 30 | #' germany <- subset(all_biodepth, all_biodepth$location == "Germany") 31 | #' 32 | #' vars <- whichVars(germany, allVars) 33 | #' species <- relevantSp(germany, 26:ncol(germany)) 34 | #' 35 | #' # re-normalize N.Soil so that everything is on the same 36 | #' # sign-scale (e.g. the maximum level of a function is 37 | #' # the "best" function) 38 | #' germany$N.Soil <- -1 * germany$N.Soil + max(germany$N.Soil, na.rm = TRUE) 39 | #' 40 | #' res.list <- lapply(vars, function(x) sAICfun(x, species, germany)) 41 | #' names(res.list) <- vars 42 | #' 43 | #' getRedundancy(vars, species, germany) 44 | #' getRedundancy(vars, species, germany, output = "coef") 45 | #' 46 | #' 47 | #' 48 | #' ######### 49 | #' # takes a vector of responses, the species that may cause them 50 | #' # and returns a table of 1s, -1s, and 0s with regards to the kind of effect 51 | #' # or a coefficient table, if asked for. Arugments can take the form of the fitting function 52 | #' # how variables are combined, and additional arguments to the fitting function 53 | #' ######### 54 | getRedundancy <- function(vars, species, data, negVars = NA, method = "lm", combine = "+", output = "effect", ...) { 55 | res.list <- lapply(vars, function(x) { 56 | positive.desired <- TRUE 57 | if (x %in% negVars) positive.desired <- F 58 | sAICfun(response = x, species = species, data = data, positive.desired, method = method, combine = combine, ...) # used to be method[idx] 59 | }) 60 | 61 | # what if they want the coefficients 62 | if (output == "coef") { 63 | # ret<-plyr::ldply(res.list, function(x) x$coefs) 64 | ret <- lapply(res.list, function(x) x$coefs) 65 | ret <- do.call(rbind, ret) %>% as.data.frame() 66 | } else { 67 | # the default of returning the 1s, -1s, and 0s 68 | # ret<-ldply(res.list, function(x) x$effects) 69 | ret <- lapply(res.list, function(x) x$effects) 70 | ret <- do.call(rbind, ret) %>% as.data.frame() 71 | } 72 | 73 | rownames(ret) <- vars 74 | return(ret) 75 | } 76 | 77 | ######### 78 | # sAICfun takes a dataset, response, and function, and then uses a stepAIC approach 79 | # to determine the best model. From that it extracts the species with a positive, 80 | # negative, and neutral effect on that function 81 | ######### 82 | sAICfun <- function(response, species, data, positive.desired = TRUE, 83 | method = "lm", combine = "+", ...) { 84 | # first fit the model 85 | obj <- sAICFit(response, species, data, method, combine, ...) 86 | 87 | # now extract the important information about positive, negative, etc. 88 | 89 | # return that info in a list 90 | if (positive.desired) { 91 | pos.sp <- names(summary(obj)[[4]][, 4][(summary(obj)[[4]][, 1] > 0) & names(summary(obj)[[4]][, 4]) != "(Intercept)"]) 92 | neg.sp <- names(summary(obj)[[4]][, 4][(summary(obj)[[4]][, 1] < 0) & names(summary(obj)[[4]][, 4]) != "(Intercept)"]) 93 | } else { 94 | pos.sp <- names(summary(obj)[[4]][, 4][(summary(obj)[[4]][, 1] < 0) & names(summary(obj)[[4]][, 4]) != "(Intercept)"]) 95 | neg.sp <- names(summary(obj)[[4]][, 4][(summary(obj)[[4]][, 1] > 0) & names(summary(obj)[[4]][, 4]) != "(Intercept)"]) 96 | } 97 | neu.sp <- species[!(species %in% pos.sp) & !(species %in% neg.sp)] 98 | 99 | # make a vector of 1s and 0s 100 | effects <- rep(0, length(species)) 101 | names(effects) <- species 102 | effects[which(names(effects) %in% pos.sp)] <- 1 103 | effects[which(names(effects) %in% neg.sp)] <- -1 104 | 105 | coefs <- c(effects, 0) 106 | names(coefs)[length(coefs)] <- "(Intercept)" 107 | coefs[match(names(coef(obj)), names(coefs))] <- coef(obj) 108 | 109 | return(list(pos.sp = pos.sp, neg.sp = neg.sp, neu.sp = neu.sp, functions = response, coefs = coefs, effects = effects)) 110 | } 111 | 112 | ######### 113 | # sAICFit does the business of fitting a model using a stepAIC approach 114 | ######### 115 | sAICFit <- function(response, species, data, method = "lm", combine = "+", ...) { 116 | f <- as.formula(paste(response, "~", paste(species, collapse = "+"))) 117 | fit <- eval(substitute(lm(f, data = data, ...))) 118 | obj <- MASS::stepAIC(fit, trace = 0) 119 | obj 120 | } 121 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the overall 26 | community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards 42 | of acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies 54 | when an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail 56 | address, posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at jarrett.byrnes@umb.edu. All complaints will be reviewed and investigated promptly and fairly. 63 | 64 | All community leaders are obligated to respect the privacy and security of the 65 | reporter of any incident. 66 | 67 | ## Enforcement Guidelines 68 | 69 | Community leaders will follow these Community Impact Guidelines in determining 70 | the consequences for any action they deem in violation of this Code of Conduct: 71 | 72 | ### 1. Correction 73 | 74 | **Community Impact**: Use of inappropriate language or other behavior deemed 75 | unprofessional or unwelcome in the community. 76 | 77 | **Consequence**: A private, written warning from community leaders, providing 78 | clarity around the nature of the violation and an explanation of why the 79 | behavior was inappropriate. A public apology may be requested. 80 | 81 | ### 2. Warning 82 | 83 | **Community Impact**: A violation through a single incident or series of 84 | actions. 85 | 86 | **Consequence**: A warning with consequences for continued behavior. No 87 | interaction with the people involved, including unsolicited interaction with 88 | those enforcing the Code of Conduct, for a specified period of time. This 89 | includes avoiding interactions in community spaces as well as external channels 90 | like social media. Violating these terms may lead to a temporary or permanent 91 | ban. 92 | 93 | ### 3. Temporary Ban 94 | 95 | **Community Impact**: A serious violation of community standards, including 96 | sustained inappropriate behavior. 97 | 98 | **Consequence**: A temporary ban from any sort of interaction or public 99 | communication with the community for a specified period of time. No public or 100 | private interaction with the people involved, including unsolicited interaction 101 | with those enforcing the Code of Conduct, is allowed during this period. 102 | Violating these terms may lead to a permanent ban. 103 | 104 | ### 4. Permanent Ban 105 | 106 | **Community Impact**: Demonstrating a pattern of violation of community 107 | standards, including sustained inappropriate behavior, harassment of an 108 | individual, or aggression toward or disparagement of classes of individuals. 109 | 110 | **Consequence**: A permanent ban from any sort of public interaction within the 111 | community. 112 | 113 | ## Attribution 114 | 115 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 116 | version 2.0, 117 | available at https://www.contributor-covenant.org/version/2/0/ 118 | code_of_conduct.html. 119 | 120 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 121 | enforcement ladder](https://github.com/mozilla/diversity). 122 | 123 | [homepage]: https://www.contributor-covenant.org 124 | 125 | For answers to common questions about this code of conduct, see the FAQ at 126 | https://www.contributor-covenant.org/faq. Translations are available at https:// 127 | www.contributor-covenant.org/translations. 128 | -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Page not found (404) • multifunc 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 | 23 |
    24 |
    76 | 77 | 78 | 79 | 80 |
    81 |
    82 | 85 | 86 | Content not found. Please use links in the navbar. 87 | 88 |
    89 | 90 | 94 | 95 |
    96 | 97 | 98 | 99 |
    103 | 104 |
    105 |

    106 |

    Site built with pkgdown 107 | 2.0.2.

    108 |
    109 | 110 |
    111 |
    112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /docs/reference/dmin.html: -------------------------------------------------------------------------------- 1 | 2 | dmin — dmin • multifunc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    Calculates the minimum non-zero value of a distance matrix

    66 |
    67 | 68 |
    69 |
    dmin(D)
    70 |
    71 | 72 |
    73 |

    Arguments

    74 |
    D
    75 |

    A distance matrix describing dissimilarity between functions.

    76 |
    77 |
    78 |

    Value

    79 |

    A numeric

    80 |
    81 | 82 |
    83 | 86 |
    87 | 88 | 89 |
    92 | 93 |
    94 |

    Site built with pkgdown 95 | 2.0.2.

    96 |
    97 | 98 |
    99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /docs/reference/duffy_2003.html: -------------------------------------------------------------------------------- 1 | 2 | Seagrass Mesocosm Data — duffy_2003 • multifunc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    Data from the a seagrass grazer diversity manipulation at the Virginia Institute of Marine Sciences. From Duffy et al. 2003 Ecology Letters.

    66 |
    67 | 68 | 69 |
    70 |

    References

    71 |

    Duffy, J. E., J. P. Richardson, and E. A. Canuel. 2003. Grazer diversity effects on ecosystem functioning in seagrass beds. Ecology letters 6:637-645.

    72 |
    73 |
    74 |

    Author

    75 |

    Jarrett Byrnes

    76 |
    77 | 78 |
    79 | 82 |
    83 | 84 | 85 |
    88 | 89 |
    90 |

    Site built with pkgdown 91 | 2.0.2.

    92 |
    93 | 94 |
    95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /docs/reference/pipe.html: -------------------------------------------------------------------------------- 1 | 2 | Pipe operator — %>% • multifunc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    See magrittr::%>% for details.

    66 |
    67 | 68 |
    69 |
    lhs %>% rhs
    70 |
    71 | 72 |
    73 |

    Arguments

    74 |
    lhs
    75 |

    A value or the magrittr placeholder.

    76 |
    rhs
    77 |

    A function call using the magrittr semantics.

    78 |
    79 |
    80 |

    Value

    81 |

    The result of calling `rhs(lhs)`.

    82 |
    83 | 84 |
    85 | 88 |
    89 | 90 | 91 |
    94 | 95 |
    96 |

    Site built with pkgdown 97 | 2.0.2.

    98 |
    99 | 100 |
    101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /docs/reference/cor_dist.html: -------------------------------------------------------------------------------- 1 | 2 | cor_dist — cor_dist • multifunc 7 | 8 | 9 |
    10 |
    54 | 55 | 56 | 57 |
    58 |
    59 | 64 | 65 |
    66 |

    Takes a data frame of functions and calculates the correlation-based 67 | distance between functions.

    68 |
    69 | 70 |
    71 |
    cor_dist(adf)
    72 |
    73 | 74 |
    75 |

    Arguments

    76 |
    adf
    77 |

    A data.frame or matrix of functions

    78 |
    79 |
    80 |

    Value

    81 |

    A matrix

    82 |
    83 | 84 |
    85 | 88 |
    89 | 90 | 91 |
    94 | 95 |
    96 |

    Site built with pkgdown 97 | 2.0.2.

    98 |
    99 | 100 |
    101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /docs/LICENSE.html: -------------------------------------------------------------------------------- 1 | 2 | MIT License • multifunc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 61 | 62 |
    63 | 64 |

    Copyright (c) 2022 Jarrett Byrnes

    65 |

    Permission is hereby granted, free of charge, to any person obtaining 66 | a copy of this software and associated documentation files (the 67 | “Software”), to deal in the Software without restriction, including 68 | without limitation the rights to use, copy, modify, merge, publish, 69 | distribute, sublicense, and/or sell copies of the Software, and to 70 | permit persons to whom the Software is furnished to do so, subject to 71 | the following conditions:

    72 |

    The above copyright notice and this permission notice shall be 73 | included in all copies or substantial portions of the Software.

    74 |

    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, 75 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 76 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 77 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 78 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 79 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 80 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    81 |
    82 | 83 |
    84 | 85 | 88 | 89 |
    90 | 91 | 92 | 93 |
    96 | 97 |
    98 |

    Site built with pkgdown 99 | 2.0.2.

    100 |
    101 | 102 |
    103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /docs/reference/standardizeZScore.html: -------------------------------------------------------------------------------- 1 | 2 | standardizeZScore — standardizeZScore • multifunc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    standardizeZScore Z-standardizes a vector.

    66 |
    67 | 68 |
    69 |
    standardizeZScore(afun)
    70 |
    71 | 72 |
    73 |

    Arguments

    74 |
    afun
    75 |

    A vector of measurements of a function.

    76 |
    77 |
    78 |

    Value

    79 |

    Returns a z-standardized vector.

    80 |
    81 |
    82 |

    Details

    83 |

    Centers a vector and divides it by its standard deviation.

    84 |
    85 |
    86 |

    Author

    87 |

    Jarrett Byrnes.

    88 |
    89 | 90 |
    91 | 94 |
    95 | 96 | 97 |
    100 | 101 |
    102 |

    Site built with pkgdown 103 | 2.0.2.

    104 |
    105 | 106 |
    107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /docs/reference/all_biodepth.html: -------------------------------------------------------------------------------- 1 | 2 | Biodepth Data — all_biodepth • multifunc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    Data from the pan-European Biodepth grassland diversity manipulation

    66 |
    67 | 68 | 69 |
    70 |

    References

    71 |

    Spehn, E. M., A. Hector, J. Joshi, M. Scherer-Lorenzen, B. Schmid, 72 | E. Bazeley-White, C. Beierkuhnlein, M. C. Caldeira, 73 | M. Diemer, P. G. Dimitrakopoulos, J. A. Finn, H. Freitas, P. S. Giller, 74 | J. Good, R. Harris, P. Hogberg, K. Huss-Danell, A. Jumpponen, J. Koricheva, 75 | P. W. Leadley, M. Loreau, A. Minns, C. P. H. Mulder, G. O'Donovan, S. J. Otway, 76 | C. Palmborg, J. S. Pereira, A. B. Pfisterer, A. Prinz, D. J. Read, E. D. Schulze, 77 | A. S. Siamantziouras, A. C. Terry, A. Y. Troumbis, F. I. Woodward, S. Yachi, and J. H. Lawton. 2005. 78 | Ecosystem effects of biodiversity manipulations in European grasslands. 79 | Ecological Monographs 75:37-63.

    80 |
    81 |
    82 |

    Author

    83 |

    Jarrett Byrnes

    84 |
    85 | 86 |
    87 | 90 |
    91 | 92 | 93 |
    96 | 97 |
    98 |

    Site built with pkgdown 99 | 2.0.2.

    100 |
    101 | 102 |
    103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /docs/reference/eff_div.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | eff_div — eff_div • multifunc 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 | 47 | 48 | 49 | 50 | 51 | 52 |
    53 |
    54 | 108 | 109 | 110 |
    111 | 112 |
    113 |
    114 | 119 | 120 |
    121 | 122 |

    eff_div effective number of functions

    123 | 124 |
    125 | 126 |
    eff_div(df, q = 1)
    127 | 128 |

    Arguments

    129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 139 | 140 |
    df

    A data frame of functions

    q

    Order of the diversity measure. Defaults to the 138 | Shannon case where q = 1. For Simpson, q=2.

    141 | 142 |

    Value

    143 | 144 |

    Returns a vector.

    145 | 146 |

    Details

    147 | 148 |

    Takes a data frame, variable names, and type of index and returns 149 | the effective number of functions - i.e., the equivalent number of 150 | functions if all were performing at the same level. See Jost 2006 and 2010. 151 | Internally, uses d

    152 | 153 | 154 |
    155 | 170 |
    171 | 172 |
    173 | 176 | 177 |
    178 |

    Site built with pkgdown.

    179 |
    180 | 181 |
    182 |
    183 | 184 | 185 | 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /docs/reference/relevantSp.html: -------------------------------------------------------------------------------- 1 | 2 | relevantSp — relevantSp • multifunc 6 | 7 | 8 |
    9 |
    53 | 54 | 55 | 56 |
    57 |
    58 | 63 | 64 |
    65 |

    relevantSp Which species are being used in this analysis.

    66 |
    67 | 68 |
    69 |
    relevantSp(data, colnums = 26:128)
    70 |
    71 | 72 |
    73 |

    Arguments

    74 |
    data
    75 |

    A data frame with presence/abscence of different species.

    76 |
    colnums
    77 |

    Column numbers that will be assessed.

    78 |
    79 |
    80 |

    Value

    81 |

    A vector of columns names.

    82 |
    83 |
    84 |

    Details

    85 |

    Which columns have values that are greater than zero.

    86 |
    87 |
    88 |

    Author

    89 |

    Jarrett Byrnes.

    90 |
    91 | 92 |
    93 | 96 |
    97 | 98 | 99 |
    102 | 103 |
    104 |

    Site built with pkgdown 105 | 2.0.2.

    106 |
    107 | 108 |
    109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /docs/reference/funcEven.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | funcEven — funcEven • multifunc 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 | 47 | 48 | 49 | 50 | 51 | 52 |
    53 |
    54 | 108 | 109 | 110 |
    111 | 112 |
    113 |
    114 | 119 | 120 |
    121 | 122 |

    funcEven evenness factor across functions

    123 | 124 |
    125 | 126 |
    funcEven(data, vars, q = 1)
    127 | 128 |

    Arguments

    129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 143 | 144 |
    data

    A vector of measurements of a function.

    vars

    Name of function variables

    q

    Order of the diversity measure. Defaults to the 142 | Shannon case where q = 1. For Simpson, q=2.

    145 | 146 |

    Value

    147 | 148 |

    Returns a vector.

    149 | 150 |

    Details

    151 | 152 |

    Takes a data frame, variable names, and type of index and gets 153 | the evenness factor for the collection of values supplied as defined in 154 | Jost 2010

    155 | 156 |

    References

    157 | 158 |

    Jost, L. 2006. Entropy and diversity. Oikos 113(2): 363-375.

    159 | 160 | 161 |
    162 | 179 |
    180 | 181 | 191 |
    192 | 193 | 194 | 195 | 196 | 197 | 198 | --------------------------------------------------------------------------------