diff --git a/R/getTaxonomy.R b/R/getTaxonomy.R index d467f28..d9429f0 100644 --- a/R/getTaxonomy.R +++ b/R/getTaxonomy.R @@ -32,7 +32,7 @@ getTaxonomy <- function(genus, findOrder = FALSE) { ################## 1. Retrieve the Family # Load taxonomical data (sourced from Angiosperm Phylogeny Website, http://www.mobot.org/MOBOT/research/APweb/) - genusFamily <- setDT(copy(BIOMASS::genusFamily)) + genusFamily <- data.table(BIOMASS::genusFamily) setkey(genusFamily, genus) # Create ids @@ -48,7 +48,7 @@ getTaxonomy <- function(genus, findOrder = FALSE) { ################## 2. Retrieve the Order if (findOrder == TRUE) { - apgFamilies <- setDT(copy(BIOMASS::apgFamilies)) + apgFamilies <- data.table(BIOMASS::apgFamilies) genusFam <- merge(genusFam, apgFamilies, by.x = "family", by.y = "famAPG", all.x = TRUE) genusFam <- genusFam[, .(id, inputGenus, family, order)] diff --git a/R/getWoodDensity.R b/R/getWoodDensity.R index efd72db..a8e11d6 100644 --- a/R/getWoodDensity.R +++ b/R/getWoodDensity.R @@ -111,7 +111,7 @@ if (getRversion() >= "2.15.1") { #' } #' @seealso [wdData], [sd_10] #' @keywords Wood density -#' @importFrom data.table data.table := setDF setDT setkey copy chmatch %chin% +#' @importFrom data.table data.table := setDF setDT setkey chmatch %chin% #' getWoodDensity <- function(genus, species, stand = NULL, family = NULL, region = "World", addWoodDensityData = NULL, verbose = TRUE) { @@ -148,11 +148,11 @@ getWoodDensity <- function(genus, species, stand = NULL, family = NULL, region = # Data processing --------------------------------------------------------- # Load global wood density database downloaded from http://datadryad.org/handle/10255/dryad.235 - wdData <- setDT(copy(BIOMASS::wdData)) + wdData <- data.table(BIOMASS::wdData) # Load the mean standard deviation observed at the species, Genus or Family level # in the Dryad dataset when at least 10 individuals are considered - sd_10 <- setDT(copy(BIOMASS::sd_10)) + sd_10 <- data.table(BIOMASS::sd_10) sd_tot <- sd(wdData$wd) Region <- tolower(region) @@ -175,7 +175,7 @@ getWoodDensity <- function(genus, species, stand = NULL, family = NULL, region = if (!is.null(addWoodDensityData)) { setDT(addWoodDensityData) if (!("family" %in% names(addWoodDensityData))) { - genusFamily <- setDT(copy(BIOMASS::genusFamily)) + genusFamily <- data.table(BIOMASS::genusFamily) addWoodDensityData[genusFamily, on = "genus", family := i.family] } addWoodDensityData <- addWoodDensityData[!is.na(wd), ] @@ -195,7 +195,7 @@ getWoodDensity <- function(genus, species, stand = NULL, family = NULL, region = inputData[, family := as.character(family)] } else { if (!exists("genusFamily", inherits = FALSE)) { - genusFamily <- setDT(copy(BIOMASS::genusFamily)) + genusFamily <- data.table(BIOMASS::genusFamily) } inputData[genusFamily, on = "genus", family := i.family] } diff --git a/data-raw/apgfamily.R b/data-raw/apgfamily.R index 9015930..f5eb17d 100644 --- a/data-raw/apgfamily.R +++ b/data-raw/apgfamily.R @@ -22,7 +22,7 @@ setDF(apgFamilies) usethis::use_data(apgFamilies, compress = "xz", overwrite = FALSE) -apgFamiliesOrg <- setDT(copy(BIOMASS::apgFamilies)) +apgFamiliesOrg <- data.table(BIOMASS::apgFamilies) apgFamiliesOrg <- apgFamiliesOrg[base::order(order)] apgFamilies <- apgFamilies[base::order(order)] diff --git a/data-raw/genusFamily.R b/data-raw/genusFamily.R index 6fa32c7..3e0f9d5 100644 --- a/data-raw/genusFamily.R +++ b/data-raw/genusFamily.R @@ -261,7 +261,7 @@ usethis::use_data(genusFamily, compress = "xz") genusFamily <- genusFamily[base::order(family)] -genusFamilyOrg <- setDT(copy(BIOMASS::genusFamily)) +genusFamilyOrg <- data.table(BIOMASS::genusFamily) genusFamilyOrg <- genusFamilyOrg[base::order(family)] result <- merge(genusFamilyOrg, genusFamily, all = T, by = "genus") diff --git a/data-raw/sd_10.R b/data-raw/sd_10.R index 78783c4..565767a 100644 --- a/data-raw/sd_10.R +++ b/data-raw/sd_10.R @@ -7,7 +7,7 @@ require(data.table) # ) # data_wd[, c("genus", "species") := tstrsplit(Binomial, " ", keep = 1:2)] -data_wd <- setDT(copy(BIOMASS::wdData)) +data_wd <- data.table(BIOMASS::wdData) species <- data_wd[, .(family, genus, wd, .N), by = species][N >= 10][, .(sd = sd(wd)), by = species][, mean(sd)]