diff --git a/.Rbuildignore b/.Rbuildignore index 4b3f9f2..5eb8c20 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,4 @@ ^.*\.Rproj$ ^\.Rproj\.user$ ^data-raw$ +^\.travis\.yml$ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ce8245c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,37 @@ +# Language is R +language: r + + +# R versions to build with ------ +# R-devel has a new method of building vignettes that breaks backward +# compatability. I will exclude it from the build matrix for now so +# workshop participants aren't confused by the build error badge. +# See below for more details on the development branch +# http://r.789695.n4.nabble.com/R-CMD-build-then-check-fails-on-R-devel-due-to-serialization-version-td4747582.html + +r: + - oldrel + - release + +# Operating systems to build on ------ +os: + - linux + - osx + +# Linux options --------- +sudo: false +dist: trusty +cache: packages + +# Branches +branches: + only: + - master + - devel + +# If anyone else would like to be added to notifications, +# just add your email below! +notifications: + email: + - jones@biology.sdu.dk + - levisc8@gmail.com diff --git a/NAMESPACE b/NAMESPACE index 3e384ee..a991b24 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,10 +1,11 @@ # Generated by roxygen2: do not edit by hand +export(DBToFlat) export(checkSpecies) -export(cleanDatabase) +export(cleanDB) export(collapseMatrix) -export(convert2flat) -export(dbCompare) +export(compareDBs) +export(findSpecies) export(getMeanMatF) export(identifyReproStages) export(mergeDBs) @@ -14,7 +15,6 @@ export(stringToMatrix) export(subsetDB) importFrom(methods,callNextMethod) importFrom(methods,new) -importFrom(methods,slotNames) importFrom(methods,validObject) importFrom(popdemo,is.matrix_ergodic) importFrom(popdemo,is.matrix_irreducible) diff --git a/R/CompadreM.R b/R/CompadreM.R index b4e8073..315611b 100644 --- a/R/CompadreM.R +++ b/R/CompadreM.R @@ -34,9 +34,10 @@ setMethod("initialize", "CompadreM", function(.Object, ...) { .Object <- methods::callNextMethod() if(length(.Object@matrixClass) == 0) { - .Object@matrixClass$MatrixClassOrganized <- character(0) - .Object@matrixClass$MatrixClassAuthor <- character(0) - .Object@matrixClass$MatrixClassNumber <- double(0) + .Object@matrixClass <- data.frame(MatrixClassOrganized = character(0), + MatrixClassAuthor = character(0), + MatrixClassNumber = double(0) + ) } methods::validObject(.Object) .Object diff --git a/R/DBToFlat.R b/R/DBToFlat.R new file mode 100644 index 0000000..d4e7c5e --- /dev/null +++ b/R/DBToFlat.R @@ -0,0 +1,64 @@ +#' Convert a list-structured COM(P)ADRE database object to a flat data frame +#' +#' This function converts a list-structured COM(P)ADRE database object to a flat +#' data frame, by converting each matrix and associated matrixClass information +#' to a string. +#' +#' @param db A COM(P)ADRE database object. Databases will be will be coerced +#' from the old 'list' format where appropriate (compadre_v4.0.1 and below; +#' comadre_v2.0.1 and below). +#' @param onlyMatA A logical value (TRUE/FALSE) indicating whether ONLY the full +#' projection matrix \code{matA} should be included in the flattened data +#' frame +#' +#' @return The \code{data.frame} from the metadata slot of \code{db}, but with +#' additional columns appended for the matrix stage information and the +#' matrices themselves, both in string format. +#' +#' @details \code{DBToFlat} is preferred, but \code{convert2flat} is provided +#' for legacy purposes. +#' +#' @author Owen R. Jones +#' +#' @seealso stringToMatrix +#' +#' @examples +#' \dontrun{ +#' compadreFlat <- DBToFlat(compadre, onlyMatA = FALSE) +#' } +#' +#' @export DBToFlat +#' +DBToFlat <- function(db, onlyMatA = FALSE){ + if (class(db) == "list"){ + if( "Animalia" %in% db$metadata$Kingdom ) vlim <- 201 + if( "Plantae" %in% db$metadata$Kingdom ) vlim <- 401 + if (as.numeric(gsub("\\.", "", sub("(\\s.*$)", "", db$version$Version))) <= vlim){ + db <- as(db, "CompadreData") + } + } + + db@metadata$Amatrix <- NULL + for (i in 1:nrow(db@metadata)){ + db@metadata$classnames[i] <- paste(db@mat[[i]]@matrixClass$MatrixClassAuthor, + collapse = " | ") + db@metadata$matrixA[i] <- paste("[", paste(t(db@mat[[i]]@matA), collapse=" "), "]", + sep = "") + } + + if(onlyMatA == FALSE) { + for (i in 1:nrow(db@metadata)){ + db@metadata$matrixU[i] <- paste("[", paste(t(db@mat[[i]]@matU), collapse=" "), + "]", sep = "") + db@metadata$matrixF[i] <- paste("[", paste(t(db@mat[[i]]@matF), collapse=" "), + "]", sep = "") + db@metadata$matrixC[i] <- paste("[", paste(t(db@mat[[i]]@matC), collapse=" "), + "]", sep = "") + } + } + + return(db@metadata) +} + +#' @rdname DBToFlat +convert2flat <- function(db, onlyMatA = FALSE){ DBToFlat(db, onlyMatA) } \ No newline at end of file diff --git a/R/checkspecies.R b/R/checkspecies.R index fd6baa5..b4c4775 100644 --- a/R/checkspecies.R +++ b/R/checkspecies.R @@ -9,28 +9,37 @@ #' @param species A character vector of binomial species names, with the #' genus and specific epithet separated by either an underscore or a space ( #' e.g. c("Acipenser_fulvescens", "Borrelia_burgdorferi")) -#' @param db A COM(P)ADRE database. -#' @param returnDatabase A logical argument indicating whether a database should be returned. -#' @return If returnDatabase = FALSE, returns a data frame with a column of -#' species names and a column indicating whether a species occurs in the -#' database. If returnDatabase == TRUE, returns a subset of db containing -#' only those species within argument \code{species} +#' @param db A COM(P)ADRE database object. Databases will be will be coerced +#' from the old 'list' format where appropriate (compadre_v4.0.1 and below; +#' comadre_v2.0.1 and below). +#' @param returnDatabase A logical argument indicating whether a database +#' should be returned. +#' +#' @return If returnDatabase = FALSE, \code{checkSpecies} returns a data frame +#' with a column of species names and a column indicating whether a species +#' occurs in the database. If returnDatabase == TRUE, returns a subset of db +#' containing only those species within argument \code{species}. +#' \code{findSpecies} returns TRUE if a species is found in the database, +#' FALSE if not, and is called by \code{checkSpecies}. +#' #' @author Danny Buss #' @author Owen R. Jones #' @author Rob Salguero-Gómez #' @author Patrick Barks +#' #' @examples #' \dontrun{ #' species <- c("Mammillaria gaumeri", "Euterpe edulis", "Homo sapiens") #' checkSpecies(species, compadre) #' compadre_subset <- checkSpecies(species, compadre, returnDatabase = TRUE) #' } -#' @importFrom rlang .data +#' #' @export checkSpecies +#' checkSpecies <- function(species, db, returnDatabase = FALSE) { # create dataframe with column for species, and column for whether they are # present in database - + inDatabase <- sapply(species, findSpecies, db = db, USE.NAMES = FALSE) df <- data.frame(species, inDatabase) @@ -39,7 +48,7 @@ checkSpecies <- function(species, db, returnDatabase = FALSE) { } if (returnDatabase == TRUE) { - ssdb <- subsetDB(db, .data$SpeciesAccepted %in% species) + ssdb <- subsetDB(db, SpeciesAccepted %in% species) return(ssdb) } else { return(df) @@ -47,10 +56,25 @@ checkSpecies <- function(species, db, returnDatabase = FALSE) { } #' Utility function for checkSpecies -#' @param x A character vector of species names -#' @param db The COM(P)ADRE database object to search in +#' +#' @rdname checkSpecies +#' +#' @param species A character vector of species names. +#' @param db A COM(P)ADRE database object. Databases will be will be coerced +#' from the old 'list' format where appropriate (compadre_v4.0.1 and below; +#' comadre_v2.0.1 and below). +#' #' @return A logical indicating whether the species name is in the -#' COM(P)ADRE object -findSpecies <- function(x, db) { - tolower(x) %in% tolower(gsub('_', ' ', db$metadata$SpeciesAccepted)) -} \ No newline at end of file +#' COM(P)ADRE object. +#' +#' @export findSpecies +findSpecies <- function(species, db) { + if (class(db) == "list"){ + if( "Animalia" %in% db$metadata$Kingdom ) vlim <- 201 + if( "Plantae" %in% db$metadata$Kingdom ) vlim <- 401 + if (as.numeric(gsub("\\.", "", sub("(\\s.*$)", "", db$version$Version))) <= vlim){ + db <- as(db, "CompadreData") + } + } + tolower(species) %in% tolower(gsub('_', ' ', db@metadata$SpeciesAccepted)) +} diff --git a/R/cleanDB.R b/R/cleanDB.R new file mode 100644 index 0000000..6df0a50 --- /dev/null +++ b/R/cleanDB.R @@ -0,0 +1,84 @@ +#' Flag potential issues in matrices of a COM(P)ADRE database. +#' +#' This function adds columns to the metatadata slot of a COM(P)ADRE database +#' object that flag potential problems in the matrices, such as when matrices +#' contain missing values. These columns can subsequently can be used to subset +#' the COM(P)ADRE database by logical argument. +#' +#' @param db A COM(P)ADRE database object. Databases will be will be coerced +#' from the old 'list' format where appropriate (compadre_v4.0.1 and below; +#' comadre_v2.0.1 and below). +#' +#' @return Returns db with extra columns appended to the metadata to indicate +#' (TRUE/FALSE) whether there are potential problems with the matrices +#' corresponding to a given row of the metadata, including whether matA is +#' ergodic, primitive, and irreducible. +#' +#' @details \code{cleanDB} is preferred, but \code{cleanDatabase} is provided +#' for legacy purposes. +#' +#' @author Julia Jones +#' @author Roberto Salguero-Goméz +#' @author Danny Buss +#' @author Patrick Barks +#' +#' @keywords utilities +#' +#' @examples +#' \dontrun{ +#' compadre_clean <- cleanDB(compadre) +#' } +#' +#' @importFrom popdemo is.matrix_ergodic is.matrix_primitive is.matrix_irreducible +#' @importFrom rlang .data +#' +#' @export cleanDB +#' +cleanDB <- function(db) { + if (class(db) == "list"){ + if( "Animalia" %in% db$metadata$Kingdom ) vlim <- 201 + if( "Plantae" %in% db$metadata$Kingdom ) vlim <- 401 + if (as.numeric(gsub("\\.", "", sub("(\\s.*$)", "", db$version$Version))) <= vlim){ + db <- as(db, "CompadreData") + } + } + + # create row index + db@metadata$index <- 1:nrow(db@metadata) + + # check matA, matU, matF, and matC for any values of NA + db@metadata$check_NA_A <- sapply(db@mat, function(x) any(is.na(x@matA))) + db@metadata$check_NA_U <- sapply(db@mat, function(x) any(is.na(x@matU))) + db@metadata$check_NA_F <- sapply(db@mat, function(x) any(is.na(x@matF))) + db@metadata$check_NA_C <- sapply(db@mat, function(x) any(is.na(x@matC))) + + # check whether any columns of matU have sums exceeding 1 + checkColsums <- function(x) any(colSums(x@matU, na.rm = T) > 1) + db@metadata$check_colsums_U <- sapply(db@mat, checkColsums) + + # check properties of matA using functions in popdemo + # these checks require matA with no values of NA + db_sub <- subsetDB(db, check_NA_A == F) # subset db to matA with no NAs + + checkErgodic <- function(x) popdemo::is.matrix_ergodic(x@matA) + checkPrimitive <- function(x) popdemo::is.matrix_primitive(x@matA) + checkIrreducible <- function(x) popdemo::is.matrix_irreducible(x@matA) + + db_sub@metadata$check_ergodic <- sapply(db_sub@mat, checkErgodic) + db_sub@metadata$check_primitive <- sapply(db_sub@mat, checkPrimitive) + db_sub@metadata$check_irreducible <- sapply(db_sub@mat, checkIrreducible) + + # merge checks into full db + db_sub@metadata <- subset(db_sub@metadata, select = c('index', + 'check_ergodic', + 'check_primitive', + 'check_irreducible')) + db@metadata <- merge(db@metadata, db_sub@metadata, by = 'index', all.x = T) + db@metadata <- subset(db@metadata, select = -index) + + # return + return(db) +} + +#' @rdname cleanDB +cleanDatabase <- function(db) { cleanDB(db) } \ No newline at end of file diff --git a/R/cleanDatabase.R b/R/cleanDatabase.R deleted file mode 100644 index 9cbe922..0000000 --- a/R/cleanDatabase.R +++ /dev/null @@ -1,63 +0,0 @@ -#' Flag potential issues in matrices of a COM(P)ADRE database. -#' -#' This function adds columns to the metatadata slot of a COM(P)ADRE database -#' object that flag potential problems in the matrices, such as when matrices -#' contain missing values. These columns can subsequently can be used to subset -#' the COM(P)ADRE database by logical argument. -#' -#' @param db A COM(P)ADRE database object. -#' @return Returns db with extra columns appended to the metadata to indicate -#' (TRUE/FALSE) whether there are potential problems with the matrices -#' corresponding to a given row of the metadata, including whether matA is -#' ergodic, primitive, and irreducible. -#' @author Julia Jones -#' Roberto Salguero-Goméz -#' Danny Buss -#' Patrick Barks -#' @keywords utilities -#' @examples -#' \dontrun{ -#' compadre_clean <- cleanDatabase(compadre) -#' } -#' -#' @importFrom popdemo is.matrix_ergodic is.matrix_primitive is.matrix_irreducible -#' @importFrom rlang .data -#' @export -cleanDatabase <- function(db) { - - # create row index - db$metadata$index <- 1:nrow(db$metadata) - - # check matA, matU, matF, and matC for any values of NA - db$metadata$check_NA_A <- sapply(db$mat, function(x) any(is.na(x$matA))) - db$metadata$check_NA_U <- sapply(db$mat, function(x) any(is.na(x$matU))) - db$metadata$check_NA_F <- sapply(db$mat, function(x) any(is.na(x$matF))) - db$metadata$check_NA_C <- sapply(db$mat, function(x) any(is.na(x$matC))) - - # check whether any columns of matU have sums exceeding 1 - checkColsums <- function(x) any(colSums(x$matU, na.rm = T) > 1) - db$metadata$check_colsums_U <- sapply(db$mat, checkColsums) - - # check properties of matA using functions in popdemo - # these checks require matA with no values of NA - db_sub <- subsetDB(db, .data$check_NA_A == F) # subset db to matA with no NAs - - checkErgodic <- function(x) popdemo::is.matrix_ergodic(x$matA) - checkPrimitive <- function(x) popdemo::is.matrix_primitive(x$matA) - checkIrreducible <- function(x) popdemo::is.matrix_irreducible(x$matA) - - db_sub$metadata$check_ergodic <- sapply(db_sub$mat, checkErgodic) - db_sub$metadata$check_primitive <- sapply(db_sub$mat, checkPrimitive) - db_sub$metadata$check_irreducible <- sapply(db_sub$mat, checkIrreducible) - - # merge checks into full db - db_sub$metadata <- subset(db_sub$metadata, select = c('index', - 'check_ergodic', - 'check_primitive', - 'check_irreducible')) - db$metadata <- merge(db$metadata, db_sub$metadata, by = 'index', all.x = T) - db$metadata <- subset(db$metadata, select = -.data$index) - - # return - return(db) -} \ No newline at end of file diff --git a/R/collapseMatrix.R b/R/collapseMatrix.R index 0ce5277..9a1760a 100644 --- a/R/collapseMatrix.R +++ b/R/collapseMatrix.R @@ -10,7 +10,6 @@ #' the stable distribution.\cr\cr #' Note: this function is only valid for models without clonality. #' -#' @export #' @param matU Survival matrix #' @param matF Fecundity matrix #' @param matC A clonality matrix @@ -20,13 +19,17 @@ #' collapsed matrix, and each element of \code{collapse} gives the stage index #' (e.g. "2") or range of stage indices (e.g. "2-3") from the original matrix #' that correspond to the relevant stage index of the collapsed matrix. +#' #' @return A list of three containing the collapsed projection matrix #' \code{matA}, collapsed survival matrix \code{matU}, and collapsed fecundity #' matrix \code{matF}. +#' #' @author Rob Salguero-Gómez +#' #' @references Salguero-Gomez, R. & Plotkin, J. B. (2010) Matrix dimensions #' bias demographic inferences: implications for comparative plant demography. #' The American Naturalist 176, 710-722. +#' #' @examples #' matU <- matrix(c(0.2581, 0.1613, 0.1935, 0.2258, 0.1613, 0.0408, 0.2857, #' 0.4286, 0.102, 0.0816, 0.0385, 0.0385, 0.2692, 0.2308, @@ -42,6 +45,9 @@ #' #' # collapse2 <- c("1-2", "3-4-5") #' # collapse3 <- c("1-2-3-4-5") +#' +#' @export collapseMatrix +#' collapseMatrix <- function(matU, matF, matC, collapse) { matA <- matU + matF + matC if (any(is.na(matA))) { diff --git a/R/compareDBs.R b/R/compareDBs.R new file mode 100644 index 0000000..9805c6b --- /dev/null +++ b/R/compareDBs.R @@ -0,0 +1,121 @@ +#' A function to compare two COMPADRE/COMADRE database versions +#' +#' A function to compare two COMPADRE/COMADRE database versions +#' +#' %% ~~ If necessary, more details than the description above ~~ +#' +#' @param db1,db2 COM(P)ADRE database objects to compare. Databases will be +#' coerced from the old 'list' format where appropriate (compadre_v4.0.1 and +#' below; comadre_v2.0.1 and below). +#' @param verbose A logical argument indicating whether or not to return lots +#' of detail. +#' +#' @return %% ~Describe the value returned %% If it is a LIST, use %% +#' +#' @details \code{compareDBs} is preferred, but \code{dbCompare} is provided +#' for legacy purposes. +#' +#' @author Owen R. Jones +#' +#' @keywords manip attribute +#' +#' @examples +#' \dontrun{ +#' compareDBs(comadreSubset,comadre,verbose = TRUE) +#' } +#' +#' @export compareDBs +#' +compareDBs <- function(db1, db2, verbose = FALSE){ + # convert legacy versions of COM(P)ADRE from class 'list' to 'CompadreData' + # convert legacy versions of COM(P)ADRE from class 'list' to 'CompadreData' + if (class(db1) == "list"){ + if( "Animalia" %in% db1$metadata$Kingdom ) vlim <- 201 + if( "Plantae" %in% db1$metadata$Kingdom ) vlim <- 401 + if (as.numeric(gsub("\\.", "", sub("(\\s.*$)", "", db1$version$Version))) <= vlim){ + db1 <- as(db1, "CompadreData") + } + } + if (class(db2) == "list"){ + if( "Animalia" %in% db2$metadata$Kingdom ) vlim <- 201 + if( "Plantae" %in% db2$metadata$Kingdom ) vlim <- 401 + if (as.numeric(gsub("\\.", "", sub("(\\s.*$)", "", db2$version$Version))) <= vlim){ + db2 <- as(db2, "CompadreData") + } + } + + #Quick summary + cat("Quick Summary\n") + + #File 1 + uniqueSource1 <- unique(paste(db1@metadata$Authors, " (", + db1@metadata$YearPublication, ") ", + db1@metadata$Journal, sep = "")) + db1@metadata$binomial <- db1@metadata$SpeciesAccepted + + cat(paste("File-1 contains the demographic and associated data from ", + length(uniqueSource1), " source papers, corresponding to ", + length(unique(db1@metadata$binomial))," accepted species, and ", + nrow(db1@metadata), " matrices.\n\n",sep="")) + + #File 2 + uniqueSource2 <- unique(paste(db2@metadata$Authors, " (", + db2@metadata$YearPublication, ") ", + db2@metadata$Journal, sep = "")) + db2@metadata$binomial <- db2@metadata$SpeciesAccepted + + cat(paste("File-2 contains the demographic and associated data for ", + length(uniqueSource2), " source papers, corresponding to ", + length(unique(db2@metadata$binomial))," accepted species, and ", + nrow(db2@metadata), " matrices.\n\n",sep="")) + + if(verbose == TRUE){ + cat("Detailed summary\n") + + #Accepted species in File 1 that are not in File 2 + sp1 <- unique(db1@metadata$binomial) + sp2 <- unique(db2@metadata$binomial) + + cat("Number of accepted species in File 1, based on latin binomial\n") + print(length(sp1)) + + cat("Number of accepted species in File 2, based on latin binomial\n") + print(length(sp2)) + + cat("Accepted species in File 1 that are not in File 2 (based on latin binomial)\n") + print(sp1[which(!sp1%in%sp2)]) + + cat("Accepted species in File 2 that are not in File 1 (based on latin binomial)\n") + print(sp2[which(!sp2%in%sp1)]) + + #Get unique author species for both files + asp1 <- unique(db1@metadata$SpeciesAuthor) + asp2 <- unique(db2@metadata$SpeciesAuthor) + + cat("Number of unique study-species combinations in File 1\n") + print(length(asp1)) + + cat("Number of unique study-species combinations in File 2\n") + print(length(asp2)) + + #cat("Study-species in File 1 that are not in File 2\n") + #print(asp1[which(!asp1%in%asp2)]) + + #cat("Study-species in File 2 that are not in File 1\n") + #print(asp2[which(!asp2%in%asp1)]) + + cat("\n\nSource papers in File 2 that are not in File 1\n") + print(sort(uniqueSource2[which(!uniqueSource2%in%uniqueSource1)])) + + cat("\n\nSource papers in File 1 that are not in File 2\n") + print(sort(uniqueSource1[which(!uniqueSource1%in%uniqueSource2)])) + + + cat("See the User Guide for definitiions\n") + } +} + +#' @rdname compareDBs +dbCompare <- function(db1, db2, verbose = FALSE) { + compareDBs(db1, db2, verbose) +} \ No newline at end of file diff --git a/R/convert2flat.R b/R/convert2flat.R deleted file mode 100644 index 915f1c5..0000000 --- a/R/convert2flat.R +++ /dev/null @@ -1,38 +0,0 @@ -#' Convert a list-structured COM(P)ADRE database object to a flat data frame -#' -#' This function converts a list-structured COM(P)ADRE database object to a flat -#' data frame, by converting each matrix and associated matrixClass information -#' to a string. -#' -#' @param db A COM(P)ADRE database object -#' @param onlyMatA A logical value (TRUE/FALSE) indicating whether ONLY the full -#' projection matrix \code{matA} should be included in the flattened data -#' frame -#' @return The \code{data.frame} from the metadata slot of \code{db}, but with -#' additional columns appended for the matrix stage information and the -#' matrices themselves, both in string format. -#' @author Owen R. Jones -#' @seealso stringtomatrix -#' @examples -#' \dontrun{ -#' compadreFlat <- convert2flat(compadre, onlyMatA = FALSE) -#' } -#' @export convert2flat -convert2flat <- function(db, onlyMatA = FALSE){ - - db$metadata$Amatrix <- NULL - for (i in 1:nrow(db$metadata)){ - db$metadata$classnames[i] <- paste(db$matrixClass[[i]]$MatrixClassAuthor,collapse=" | ") - db$metadata$matrixA[i] <- paste("[",paste(t(db$mat[[i]]$matA),collapse=" "),"]",sep="") - } - - if(onlyMatA == FALSE) { - for (i in 1:nrow(db$metadata)){ - db$metadata$matrixU[i] <- paste("[",paste(t(db$mat[[i]]$matU),collapse=" "),"]",sep="") - db$metadata$matrixF[i] <- paste("[",paste(t(db$mat[[i]]$matF),collapse=" "),"]",sep="") - db$metadata$matrixC[i] <- paste("[",paste(t(db$mat[[i]]$matC),collapse=" "),"]",sep="") - } - } - - return(db$metadata) -} diff --git a/R/dbCompare.R b/R/dbCompare.R deleted file mode 100644 index fdb0820..0000000 --- a/R/dbCompare.R +++ /dev/null @@ -1,87 +0,0 @@ -#' A function to compare two COMPADRE/COMADRE database versions -#' -#' A function to compare two COMPADRE/COMADRE database versions -#' -#' %% ~~ If necessary, more details than the description above ~~ -#' -#' @param db1 The name of the first database object in the comparison. -#' @param db2 The name of the second database object in the comparison. -#' @param verbose A logical argument indicating whether or not to return lots -#' of detail. -#' @return %% ~Describe the value returned %% If it is a LIST, use %% -#' @author Owen R. Jones -#' @keywords manip attribute -#' @examples -#' \dontrun{ -#' dbCompare(comadreSubset,comadre,verbose = TRUE) -#' } -#' -#' @export dbCompare -dbCompare <- function(db1, db2, verbose = FALSE){ - -#Quick summary -cat("Quick Summary\n") - -#File 1 -uniqueSource1 <- unique(paste(db1$metadata$Authors," (",db1$metadata$YearPublication,") ",db1$metadata$Journal,sep="")) -db1$metadata$binomial <- paste(db1$metadata$GenusAccepted,db1$metadata$SpeciesEpithetAccepted,sep = " ") - -cat(paste("File-1 contains the demographic and associated data from ", - length(uniqueSource1), " source papers, corresponding to ", - length(unique(db1$metadata$binomial))," accepted species, and ", - nrow(db1$metadata), " matrices.\n\n",sep="")) - -#File 2 -uniqueSource2 <- unique(paste(db2$metadata$Authors," (",db2$metadata$YearPublication,") ",db2$metadata$Journal,sep="")) -db2$metadata$binomial <- paste(db2$metadata$GenusAccepted,db2$metadata$SpeciesEpithetAccepted,sep = " ") - -cat(paste("File-2 contains the demographic and associated data for ", - length(uniqueSource2), " source papers, corresponding to ", - length(unique(db2$metadata$binomial))," accepted species, and ", - nrow(db2$metadata), " matrices.\n\n",sep="")) - -if(verbose == TRUE){ -cat("Detailed summary\n") - -#Accepted species in File 1 that are not in File 2 -sp1 <- unique(db1$metadata$binomial) -sp2 <- unique(db2$metadata$binomial) - -cat("Number of accepted species in File 1, based on latin binomial\n") -print(length(sp1)) - -cat("Number of accepted species in File 2, based on latin binomial\n") -print(length(sp2)) - -cat("Accepted species in File 1 that are not in File 2 (based on latin binomial)\n") -print(sp1[which(!sp1%in%sp2)]) - -cat("Accepted species in File 2 that are not in File 1 (based on latin binomial)\n") -print(sp2[which(!sp2%in%sp1)]) - -#Get unique author species for both files -asp1 <- unique(db1$metadata$SpeciesAuthor) -asp2 <- unique(db2$metadata$SpeciesAuthor) - -cat("Number of unique study-species combinations in File 1\n") -print(length(asp1)) - -cat("Number of unique study-species combinations in File 2\n") -print(length(asp2)) - -#cat("Study-species in File 1 that are not in File 2\n") -#print(asp1[which(!asp1%in%asp2)]) - -#cat("Study-species in File 2 that are not in File 1\n") -#print(asp2[which(!asp2%in%asp1)]) - -cat("\n\nSource papers in File 2 that are not in File 1\n") -print(sort(uniqueSource2[which(!uniqueSource2%in%uniqueSource1)])) - -cat("\n\nSource papers in File 1 that are not in File 2\n") -print(sort(uniqueSource1[which(!uniqueSource1%in%uniqueSource2)])) - - -cat("See the User Guide for definitiions\n") -} -} diff --git a/R/getMeanMatF.R b/R/getMeanMatF.R index df907d9..1b09d6f 100644 --- a/R/getMeanMatF.R +++ b/R/getMeanMatF.R @@ -12,14 +12,19 @@ #' fecundity in a given stage class and year does not necessarily indicate that #' the stage in question is non-reproductive). #' -#' @param db A COM(P)ADRE database object. +#' @param db A COM(P)ADRE database object. Databases will be will be coerced +#' from the old 'list' format where appropriate (compadre_v4.0.1 and below; +#' comadre_v2.0.1 and below). +#' #' @return Returns a list which contains the mean fecundity matrix associated #' with a given row of the database, or NA if there is only a single matrix #' from the relevant population within the db. +#' #' @author Danny Buss #' @author Julia Jones #' @author Iain Stott #' @author Patrick Barks +#' #' @examples #' \dontrun{ #' # print set of matrices (A, U, F, C) associated with row 2 of database @@ -31,10 +36,22 @@ #' # print meanMatF associated with row 2 of database #' compadre_with_meanF$mat[[2]] #' } -#' @export +#' #' @importFrom rlang .data +#' +#' @export getMeanMatF +#' getMeanMatF <- function(db) { - + + # convert legacy versions of COM(P)ADRE from class 'list' to 'CompadreData' + if (class(db) == "list"){ + if( "Animalia" %in% db$metadata$Kingdom ) vlim <- 201 + if( "Plantae" %in% db$metadata$Kingdom ) vlim <- 401 + if (as.numeric(gsub("\\.", "", sub("(\\s.*$)", "", db$version$Version))) <= vlim){ + db <- as(db, "CompadreData") + } + } + # create a unique identifier for each population in the database db@metadata$PopId <- as.numeric(as.factor(paste( db@metadata$Authors, diff --git a/R/identifyReprodStages.R b/R/identifyReprodStages.R index 8241a3f..7046521 100644 --- a/R/identifyReprodStages.R +++ b/R/identifyReprodStages.R @@ -6,11 +6,11 @@ #' combined propagule, pre-reproductive, reproductive and post-reproductive #' stages. #' -#' @export #' @param matF A fecundity matrix #' @param na.handling One of \code{"return.na"}, \code{"return.true"}, or #' \code{"return.false"}. Determines how values of \code{NA} within #' \code{matF} should be handled. See Value for more details. +#' #' @return A logical vector of length \code{ncol(matF)}, with values of #' \code{FALSE} corresponding to non-reproductive stages and values of #' \code{TRUE} corresponding to reproductive stages.\cr\cr For a given matrix @@ -20,8 +20,10 @@ #' of \code{NA}, the function will return \code{NA} if \code{na.handling == #' "return.na"}, \code{TRUE} if \code{na.handling == "return.true"}, or #' \code{FALSE} if \code{na.handling == "return.false"}. +#' #' @author Rob Salguero-Gómez #' @author Patrick Barks +#' #' @examples #' matF1 <- rbind(c(0, 0.2, 0, 0.5, 0), c(0, 0.3, 0.2, 0.6, 0), c(0, 0, 0, 0, #' 0), c(0, 0, 0, 0, 0), c(0, 0, 0, 0, 0)) @@ -40,6 +42,9 @@ #' # invalid setting for argument na.handling #' identifyReproStages(matF2, na.handling = "NA") #' } +#' +#' @export identifyReproStages +#' identifyReproStages <- function(matF, na.handling = "return.true") { if (!na.handling %in% c("return.na", "return.true", "return.false")) { stop("Argument na.handling must be either 'return.na', 'return.true', or 'return.false'") diff --git a/R/mergeDBs.R b/R/mergeDBs.R index 00822f3..afdddc5 100644 --- a/R/mergeDBs.R +++ b/R/mergeDBs.R @@ -25,8 +25,9 @@ #' } #' #' @importFrom methods new -#' @export - +#' +#' @export mergeDBs +#' mergeDBs <- function(db1, db2) { if(!inherits(db1, 'CompadreData')) { @@ -63,8 +64,7 @@ mergeDBs <- function(db1, db2) { stop("Something went wrong. Send a reproducible", " example to levisc8@gmail.com ") } - - + # If the user hasn't used subset DB to create the smaller versions, # then add in that information. # I will work on making these messages a bit prettier in the not diff --git a/R/rearrangeMatrix.R b/R/rearrangeMatrix.R index ed14e21..bd043b9 100644 --- a/R/rearrangeMatrix.R +++ b/R/rearrangeMatrix.R @@ -5,11 +5,11 @@ #' the matrix model into a standardized set of stages (e.g. propagule, #' pre-reproductive, reproductive, and post-reproductive). #' -#' @export #' @param matU Survival matrix #' @param matF Fecundity matrix #' @param matrixStages A character vector identifying the matrix stages #' @param reproStages Logical vector identifying which stages reproductive +#' #' @return Returns a list with 5 elements: the rearranged survival matrix #' (\code{matU}), the rearranged fecundity matrix (\code{matF}), the #' rearranged vector of reproductive stages (\code{reproStages}), the numeric @@ -18,6 +18,7 @@ #' reproductive stage vector (\code{maxRep}). #' #' @author Rob Salguero-Gómez +#' #' @examples #' matU <- rbind(c(0, 0, 0, 0, 0), c(0.1, 0.16, 0, 0, 0), c(0.2, 0.23, 0.12, 0, #' 0), c(0, 0, 0.34, 0.53, 0), c(0, 0, 0, 0.34, 0)) @@ -29,6 +30,7 @@ #' matrixStages <- c('prop', 'active', 'active', 'active', 'active') #' rearrangeMatrix(matU, matF, reproStages, matrixStages) #' +#' @export rearrangeMatrix #' rearrangeMatrix <- function(matU, matF, reproStages, matrixStages) { if (!(identical(dim(matU), dim(matF)) && identical(ncol(matF), diff --git a/R/splitMatrix.R b/R/splitMatrix.R index 4e45e32..02801e9 100644 --- a/R/splitMatrix.R +++ b/R/splitMatrix.R @@ -4,15 +4,19 @@ #' Warning! The functionality is very basic - it assumes that sexual reproduction is located in the top row of the matrix, and that everything else is growth or survival (the U matrix). Clonality is assumed to be non-existant. #' #' @param matA A matrix population model. +#' #' @return A list of three matrices: `matU`,`matF` and `matC`. +#' #' @author Owen R. Jones +#' #' @examples #' \dontrun{library(popdemo) #' data(Tort) #' splitMatrix(Tort) #' } +#' #' @export splitMatrix - +#' splitMatrix <- function(matA){ matU <- matA matU[1,] <- rep(0,ncol(matA)) diff --git a/R/stringtomatrix.R b/R/stringtomatrix.R index d2d00d7..4ed32b7 100644 --- a/R/stringtomatrix.R +++ b/R/stringtomatrix.R @@ -6,9 +6,13 @@ #' @param A A square matrix in the form of a string, begining with an open #' square bracket and ending with a closed square bracket, with individual #' matrix cell entries separated by a space. +#' #' @return A square numeric \code{matrix}. +#' #' @author Owen R. Jones -#' @seealso convert2flat +#' +#' @seealso DBToFlat +#' #' @examples #' x1 <- "[3.3 5.2 6.1 0.1 NA 0.3 0.2 0.4 0.1]" #' stringToMatrix(x1) @@ -21,7 +25,9 @@ #' x3 <- "[0.42 0.52 0.15 0.23 0.14]" #' stringToMatrix(x3) #' } -#' @export +#' +#' @export stringToMatrix +#' stringToMatrix <- function(A) { A <- gsub(pattern = "\\[|\\]", "", A) A <- gsub(pattern = ";", " ", A) diff --git a/R/subsetDB.R b/R/subsetDB.R index 17600c1..871ec3f 100644 --- a/R/subsetDB.R +++ b/R/subsetDB.R @@ -2,15 +2,20 @@ #' #' Subset the COMPADRE/COMADRE database by logical argument. #' +#' @param db A COM(P)ADRE database object. Databases will be will be coerced +#' from the old 'list' format where appropriate (compadre_v4.0.1 and below; +#' comadre_v2.0.1 and below). #' @param sub An argument made using logical operators (see `subset`) with #' which to subset the data base. Any of the variables contained in the #' metadata part of the COMPADRE/COMADRE database may be used. -#' @param db The COMPADRE or COMADRE database object. +#' #' @return Returns a subset of the database, with the same structure, but where #' the records in the metadata match the criteria given in the `sub` argument. +#' #' @author Owen R. Jones -#' Rob Salguero-Gómez -#' Bruce Kendall +#' @author Rob Salguero-Gómez +#' @author Bruce Kendall +#' #' @examples #' \dontrun{ #' ssData <- subsetDB(compadre, MatrixDimension > 3) @@ -18,9 +23,18 @@ #' ssData <- subsetDB(comadre, Continent == "Africa" & Class == "Mammalia") #' ssData <- subsetDB(comadre, Altitude > 1000 & Altitude < 1500) #' } +#' #' @export subsetDB -#' @importFrom methods slotNames -subsetDB <- function(db, sub) { +#' +subsetDB <- function(db, sub){ + # convert legacy versions of COM(P)ADRE from class 'list' to 'CompadreData' + if (class(db) == "list"){ + if( "Animalia" %in% db$metadata$Kingdom ) vlim <- 201 + if( "Plantae" %in% db$metadata$Kingdom ) vlim <- 401 + if (as.numeric(gsub("\\.", "", sub("(\\s.*$)", "", db$version$Version))) <= vlim){ + db <- as(db, "CompadreData") + } + } e <- substitute(sub) r <- eval(e, db@metadata, parent.frame()) @@ -32,34 +46,23 @@ subsetDB <- function(db, sub) { # Subset the sub-parts of the database ssdb@metadata <- ssdb@metadata[subsetID,] ssdb@mat <- ssdb@mat[subsetID] - - # Version information is retained, but modified as follows - if("version" %in% methods::slotNames(ssdb)) { - - ssdb@version$Version <- paste0( - ssdb@version$Version, - " - subset created on ", - format(Sys.time(), "%b_%d_%Y") - ) - - ssdb@version$DateCreated <- paste0( - ssdb@version$DateCreated, - " - subset created on ", - format(Sys.time(), "%b_%d_%Y") - ) - - ssdb@version$NumberAcceptedSpecies <- length( - unique(ssdb@metadata$SpeciesAccepted) - ) - - ssdb@version$NumberStudies <- length( - unique(paste0(ssdb@metadata$Authors, - ssdb@metadata$Journal, - ssdb@metadata$YearPublication)) - ) - + + # Version information is retained, but modified as follows. + if("version" %in% slotNames(ssdb)){ + ssdb@version$Version <- paste0(ssdb@version$Version, + " - subset created on ", + format(Sys.time(), "%b_%d_%Y") + ) + ssdb@version$DateCreated <- paste0(ssdb@version$DateCreated, + " - subset created on ", + format(Sys.time(), "%b_%d_%Y") + ) + ssdb@version$NumberAcceptedSpecies <- length(unique(ssdb@metadata$SpeciesAccepted)) + ssdb@version$NumberStudies <- length(unique(paste0(ssdb@metadata$Authors, + ssdb@metadata$Journal, + ssdb@metadata$YearPublication + ))) ssdb@version$NumberMatrices <- length(ssdb@mat) } - return(ssdb) } \ No newline at end of file diff --git a/README.md b/README.md index 77c8522..4c21232 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +[![Travis-CI Build Status](https://travis-ci.org/jonesor/Rcompadre.svg?branch=devel)](https://travis-ci.org/jonesor/Rcompadre) + + Rcompadre ========== diff --git a/man/convert2flat.Rd b/man/DBToFlat.Rd similarity index 64% rename from man/convert2flat.Rd rename to man/DBToFlat.Rd index 89f4d08..5ab19c0 100644 --- a/man/convert2flat.Rd +++ b/man/DBToFlat.Rd @@ -1,13 +1,18 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/convert2flat.R -\name{convert2flat} +% Please edit documentation in R/DBToFlat.R +\name{DBToFlat} +\alias{DBToFlat} \alias{convert2flat} \title{Convert a list-structured COM(P)ADRE database object to a flat data frame} \usage{ +DBToFlat(db, onlyMatA = FALSE) + convert2flat(db, onlyMatA = FALSE) } \arguments{ -\item{db}{A COM(P)ADRE database object} +\item{db}{A COM(P)ADRE database object. Databases will be will be coerced + from the old 'list' format where appropriate (compadre_v4.0.1 and below; +comadre_v2.0.1 and below).} \item{onlyMatA}{A logical value (TRUE/FALSE) indicating whether ONLY the full projection matrix \code{matA} should be included in the flattened data @@ -23,13 +28,18 @@ This function converts a list-structured COM(P)ADRE database object to a flat data frame, by converting each matrix and associated matrixClass information to a string. } +\details{ +\code{DBToFlat} is preferred, but \code{convert2flat} is provided +for legacy purposes. +} \examples{ \dontrun{ -compadreFlat <- convert2flat(compadre, onlyMatA = FALSE) +compadreFlat <- DBToFlat(compadre, onlyMatA = FALSE) } + } \seealso{ -stringtomatrix +stringToMatrix } \author{ Owen R. Jones diff --git a/man/checkSpecies.Rd b/man/checkSpecies.Rd index 7bb7260..315665b 100644 --- a/man/checkSpecies.Rd +++ b/man/checkSpecies.Rd @@ -2,24 +2,41 @@ % Please edit documentation in R/checkspecies.R \name{checkSpecies} \alias{checkSpecies} +\alias{findSpecies} \title{Check whether a COM(P)ADRE database contains one or more species of interest} \usage{ checkSpecies(species, db, returnDatabase = FALSE) + +findSpecies(species, db) } \arguments{ \item{species}{A character vector of binomial species names, with the genus and specific epithet separated by either an underscore or a space ( e.g. c("Acipenser_fulvescens", "Borrelia_burgdorferi"))} -\item{db}{A COM(P)ADRE database.} +\item{db}{A COM(P)ADRE database object. Databases will be will be coerced + from the old 'list' format where appropriate (compadre_v4.0.1 and below; +comadre_v2.0.1 and below).} + +\item{returnDatabase}{A logical argument indicating whether a database +should be returned.} + +\item{species}{A character vector of species names.} -\item{returnDatabase}{A logical argument indicating whether a database should be returned.} +\item{db}{A COM(P)ADRE database object. Databases will be will be coerced + from the old 'list' format where appropriate (compadre_v4.0.1 and below; +comadre_v2.0.1 and below).} } \value{ -If returnDatabase = FALSE, returns a data frame with a column of - species names and a column indicating whether a species occurs in the - database. If returnDatabase == TRUE, returns a subset of db containing - only those species within argument \code{species} +If returnDatabase = FALSE, \code{checkSpecies} returns a data frame + with a column of species names and a column indicating whether a species + occurs in the database. If returnDatabase == TRUE, returns a subset of db + containing only those species within argument \code{species}. + \code{findSpecies} returns TRUE if a species is found in the database, + FALSE if not, and is called by \code{checkSpecies}. + +A logical indicating whether the species name is in the +COM(P)ADRE object. } \description{ This function takes a vector of species names and checks whether those @@ -27,6 +44,8 @@ species are represented within a COM(P)ADRE database. It outputs either a data frame depicting the species of interest and whether they occurr in the database (TRUE/FALSE), or, if returnDatabase == TRUE, a COM(P)ADRE database object subset to the species of interest. + +Utility function for checkSpecies } \examples{ \dontrun{ @@ -34,6 +53,7 @@ species <- c("Mammillaria gaumeri", "Euterpe edulis", "Homo sapiens") checkSpecies(species, compadre) compadre_subset <- checkSpecies(species, compadre, returnDatabase = TRUE) } + } \author{ Danny Buss diff --git a/man/cleanDatabase.Rd b/man/cleanDB.Rd similarity index 61% rename from man/cleanDatabase.Rd rename to man/cleanDB.Rd index 0783ea2..866e57e 100644 --- a/man/cleanDatabase.Rd +++ b/man/cleanDB.Rd @@ -1,13 +1,18 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/cleanDatabase.R -\name{cleanDatabase} +% Please edit documentation in R/cleanDB.R +\name{cleanDB} +\alias{cleanDB} \alias{cleanDatabase} \title{Flag potential issues in matrices of a COM(P)ADRE database.} \usage{ +cleanDB(db) + cleanDatabase(db) } \arguments{ -\item{db}{A COM(P)ADRE database object.} +\item{db}{A COM(P)ADRE database object. Databases will be will be coerced + from the old 'list' format where appropriate (compadre_v4.0.1 and below; +comadre_v2.0.1 and below).} } \value{ Returns db with extra columns appended to the metadata to indicate @@ -21,16 +26,23 @@ object that flag potential problems in the matrices, such as when matrices contain missing values. These columns can subsequently can be used to subset the COM(P)ADRE database by logical argument. } +\details{ +\code{cleanDB} is preferred, but \code{cleanDatabase} is provided +for legacy purposes. +} \examples{ \dontrun{ -compadre_clean <- cleanDatabase(compadre) +compadre_clean <- cleanDB(compadre) } } \author{ Julia Jones -Roberto Salguero-Goméz -Danny Buss -Patrick Barks + +Roberto Salguero-Goméz + +Danny Buss + +Patrick Barks } \keyword{utilities} diff --git a/man/collapseMatrix.Rd b/man/collapseMatrix.Rd index 5fdc7cf..b0eda33 100644 --- a/man/collapseMatrix.Rd +++ b/man/collapseMatrix.Rd @@ -51,6 +51,7 @@ collapseMatrix(matU, matF, matC, collapse1) # collapse2 <- c("1-2", "3-4-5") # collapse3 <- c("1-2-3-4-5") + } \references{ Salguero-Gomez, R. & Plotkin, J. B. (2010) Matrix dimensions diff --git a/man/dbCompare.Rd b/man/compareDBs.Rd similarity index 57% rename from man/dbCompare.Rd rename to man/compareDBs.Rd index 6f740c3..8419b16 100644 --- a/man/dbCompare.Rd +++ b/man/compareDBs.Rd @@ -1,15 +1,18 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/dbCompare.R -\name{dbCompare} +% Please edit documentation in R/compareDBs.R +\name{compareDBs} +\alias{compareDBs} \alias{dbCompare} \title{A function to compare two COMPADRE/COMADRE database versions} \usage{ +compareDBs(db1, db2, verbose = FALSE) + dbCompare(db1, db2, verbose = FALSE) } \arguments{ -\item{db1}{The name of the first database object in the comparison.} - -\item{db2}{The name of the second database object in the comparison.} +\item{db1, db2}{COM(P)ADRE database objects to compare. Databases will be +coerced from the old 'list' format where appropriate (compadre_v4.0.1 and +below; comadre_v2.0.1 and below).} \item{verbose}{A logical argument indicating whether or not to return lots of detail.} @@ -22,10 +25,13 @@ A function to compare two COMPADRE/COMADRE database versions } \details{ %% ~~ If necessary, more details than the description above ~~ + +\code{compareDBs} is preferred, but \code{dbCompare} is provided +for legacy purposes. } \examples{ \dontrun{ - dbCompare(comadreSubset,comadre,verbose = TRUE) + compareDBs(comadreSubset,comadre,verbose = TRUE) } } diff --git a/man/findSpecies.Rd b/man/findSpecies.Rd deleted file mode 100644 index fcdcc65..0000000 --- a/man/findSpecies.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/checkspecies.R -\name{findSpecies} -\alias{findSpecies} -\title{Utility function for checkSpecies} -\usage{ -findSpecies(x, db) -} -\arguments{ -\item{x}{A character vector of species names} - -\item{db}{The COM(P)ADRE database object to search in} -} -\value{ -A logical indicating whether the species name is in the -COM(P)ADRE object -} -\description{ -Utility function for checkSpecies -} diff --git a/man/getMeanMatF.Rd b/man/getMeanMatF.Rd index 94970c5..13f1737 100644 --- a/man/getMeanMatF.Rd +++ b/man/getMeanMatF.Rd @@ -8,7 +8,9 @@ matrices in a COM(P)ADRE database object} getMeanMatF(db) } \arguments{ -\item{db}{A COM(P)ADRE database object.} +\item{db}{A COM(P)ADRE database object. Databases will be will be coerced + from the old 'list' format where appropriate (compadre_v4.0.1 and below; +comadre_v2.0.1 and below).} } \value{ Returns a list which contains the mean fecundity matrix associated @@ -38,6 +40,7 @@ meanF <- getMeanMatF(compadre) # print meanMatF associated with row 2 of database compadre_with_meanF$mat[[2]] } + } \author{ Danny Buss diff --git a/man/identifyReproStages.Rd b/man/identifyReproStages.Rd index 3518ccf..9da45d8 100644 --- a/man/identifyReproStages.Rd +++ b/man/identifyReproStages.Rd @@ -49,6 +49,7 @@ identifyReproStages(matF2, na.handling = "return.false") # invalid setting for argument na.handling identifyReproStages(matF2, na.handling = "NA") } + } \author{ Rob Salguero-Gómez diff --git a/man/rearrangeMatrix.Rd b/man/rearrangeMatrix.Rd index 2f5216d..af46294 100644 --- a/man/rearrangeMatrix.Rd +++ b/man/rearrangeMatrix.Rd @@ -40,7 +40,6 @@ reproStages <- c(FALSE, TRUE, FALSE, TRUE, FALSE) matrixStages <- c('prop', 'active', 'active', 'active', 'active') rearrangeMatrix(matU, matF, reproStages, matrixStages) - } \author{ Rob Salguero-Gómez diff --git a/man/splitMatrix.Rd b/man/splitMatrix.Rd index 7158a24..fee1037 100644 --- a/man/splitMatrix.Rd +++ b/man/splitMatrix.Rd @@ -21,6 +21,7 @@ Warning! The functionality is very basic - it assumes that sexual reproduction i data(Tort) splitMatrix(Tort) } + } \author{ Owen R. Jones diff --git a/man/stringtomatrix.Rd b/man/stringtomatrix.Rd index c312743..d18ab19 100644 --- a/man/stringtomatrix.Rd +++ b/man/stringtomatrix.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/stringtomatrix.R +% Please edit documentation in R/stringToMatrix.R \name{stringToMatrix} \alias{stringToMatrix} \title{Converts a matrix in character string format to numeric matrix format} @@ -30,9 +30,10 @@ stringToMatrix(x2) x3 <- "[0.42 0.52 0.15 0.23 0.14]" stringToMatrix(x3) } + } \seealso{ -convert2flat +DBToFlat } \author{ Owen R. Jones diff --git a/man/subsetDB.Rd b/man/subsetDB.Rd index 3d3079e..d516379 100644 --- a/man/subsetDB.Rd +++ b/man/subsetDB.Rd @@ -7,7 +7,9 @@ subsetDB(db, sub) } \arguments{ -\item{db}{The COMPADRE or COMADRE database object.} +\item{db}{A COM(P)ADRE database object. Databases will be will be coerced + from the old 'list' format where appropriate (compadre_v4.0.1 and below; +comadre_v2.0.1 and below).} \item{sub}{An argument made using logical operators (see `subset`) with which to subset the data base. Any of the variables contained in the @@ -27,9 +29,12 @@ ssData <- subsetDB(compadre, MatrixDimension > 3 & MatrixComposite == "Mean") ssData <- subsetDB(comadre, Continent == "Africa" & Class == "Mammalia") ssData <- subsetDB(comadre, Altitude > 1000 & Altitude < 1500) } + } \author{ Owen R. Jones + Rob Salguero-Gómez + Bruce Kendall }