diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION new file mode 100644 index 0000000..1690682 --- /dev/null +++ b/CRAN-SUBMISSION @@ -0,0 +1,3 @@ +Version: 1.2.5 +Date: 2022-02-21 22:34:33 UTC +SHA: 67ba4a8b5570bed36553e7d14e7e653413574267 diff --git a/R/BIEN.R b/R/BIEN.R index 263df93..634c735 100644 --- a/R/BIEN.R +++ b/R/BIEN.R @@ -12,10 +12,20 @@ #' BIEN_occurrence_species("Abies amabilis") #' species_vector<-c("Abies amabilis", "Acer nigrum") #' BIEN_occurrence_species(species_vector) -#' BIEN_occurrence_species(species_vector,all.taxonomy=TRUE)} +#' BIEN_occurrence_species(species_vector,all.taxonomy = TRUE)} #' @family occurrence functions #' @export -BIEN_occurrence_species<-function(species,cultivated=FALSE,new.world=NULL,all.taxonomy=FALSE,native.status=FALSE,natives.only=TRUE,observation.type=FALSE,political.boundaries=FALSE,collection.info=F,only.geovalid=T, ...){ +BIEN_occurrence_species<-function(species, + cultivated = FALSE, + new.world = NULL, + all.taxonomy = FALSE, + native.status = FALSE, + natives.only = TRUE, + observation.type = FALSE, + political.boundaries = FALSE, + collection.info = FALSE, + only.geovalid = TRUE, + ...){ #Test input .is_log(cultivated) @@ -75,7 +85,16 @@ BIEN_occurrence_species<-function(species,cultivated=FALSE,new.world=NULL,all.ta #' species_occurrences<-BIEN_occurrence_spatialpolygons(spatialpolygons=sp)} #' @family occurrence functions #' @export -BIEN_occurrence_spatialpolygons<-function(spatialpolygons,cultivated=FALSE,new.world=NULL,all.taxonomy=FALSE,native.status=FALSE,natives.only=TRUE,observation.type=FALSE,political.boundaries=FALSE,collection.info=F,...){ +BIEN_occurrence_spatialpolygons<-function(spatialpolygons, + cultivated = FALSE, + new.world = NULL, + all.taxonomy = FALSE, + native.status = FALSE, + natives.only = TRUE, + observation.type = FALSE, + political.boundaries = FALSE, + collection.info = FALSE, + ...){ .is_log(cultivated) .is_log_or_null(new.world) .is_log(all.taxonomy) @@ -232,7 +251,13 @@ BIEN_list_country <- function(country = NULL, #' BIEN_list_state(country="United States", state= state_vector)} #' @family list functions #' @export -BIEN_list_state<-function(country=NULL,country.code=NULL,state=NULL,state.code=NULL,cultivated=FALSE,new.world=NULL,...){ +BIEN_list_state <- function(country = NULL, + country.code = NULL, + state = NULL, + state.code = NULL, + cultivated = FALSE, + new.world = NULL, + ...){ .is_char(country) .is_char(country.code) .is_char(state) @@ -534,7 +559,10 @@ BIEN_list_all<-function( ...){ #' @family list functions #' @importFrom rgeos writeWKT #' @export -BIEN_list_spatialpolygons<-function(spatialpolygons,cultivated=FALSE,new.world=NULL,...){ +BIEN_list_spatialpolygons <- function(spatialpolygons, + cultivated = FALSE, + new.world = NULL, + ...){ .is_log(cultivated) .is_log_or_null(new.world) @@ -611,7 +639,16 @@ BIEN_list_spatialpolygons<-function(spatialpolygons,cultivated=FALSE,new.world=N #' BIEN_occurrence_genus(genus = "Abutilon",cultivated = TRUE,new.world = FALSE)} #' @family occurrence functions #' @export -BIEN_occurrence_genus<-function(genus,cultivated=FALSE,new.world=NULL,all.taxonomy=FALSE,native.status=FALSE,natives.only=TRUE,observation.type=FALSE,political.boundaries=FALSE,collection.info=F, ...){ +BIEN_occurrence_genus <- function(genus, + cultivated = FALSE, + new.world = NULL, + all.taxonomy = FALSE, + native.status = FALSE, + natives.only = TRUE, + observation.type = FALSE, + political.boundaries = FALSE, + collection.info = FALSE, + ...){ .is_char(genus) .is_log(cultivated) .is_log(all.taxonomy) @@ -658,7 +695,17 @@ BIEN_occurrence_genus<-function(genus,cultivated=FALSE,new.world=NULL,all.taxono #' BIEN_occurrence_family(family_vector)} #' @family occurrence functions #' @export -BIEN_occurrence_family<-function(family,cultivated=FALSE,new.world=NULL,observation.type=FALSE,all.taxonomy=FALSE,native.status=FALSE,natives.only=TRUE,political.boundaries=FALSE,collection.info=F, ...){ +BIEN_occurrence_family <- function(family, + cultivated = FALSE, + new.world = NULL, + observation.type = FALSE, + all.taxonomy = FALSE, + native.status = FALSE, + natives.only = TRUE, + political.boundaries = FALSE, + collection.info = FALSE, + ...){ + .is_char(family) .is_log(cultivated) .is_log_or_null(new.world) @@ -1173,7 +1220,7 @@ BIEN_occurrence_box<-function(min.lat, #' #Plotting files #' plot(Abies_poly)#plots the range, but doesn't mean much without any reference #' map('world', fill = TRUE, col = "grey")#plots a world map (WGS84 projection), in grey -#' plot(Abies_poly,col="forest green",add=TRUE) #adds the range of Abies lasiocarpa to the map +#' plot(Abies_poly,col="forest green",add = TRUE) #adds the range of Abies lasiocarpa to the map #' #' #Getting data from the files (currently only species names) #' Abies_poly$Species#gives the species name associated with "Abies_poly"} @@ -1195,7 +1242,7 @@ BIEN_ranges_species<-function(species, #make sure there are no spaces in the species names species<-gsub(" ","_",species) - if(match_names_only==FALSE){ + if(match_names_only == FALSE){ #record original working directory,change to specified directory if given if(is.null(directory)){ @@ -1229,13 +1276,13 @@ BIEN_ranges_species<-function(species, directory<-paste(unlist(strsplit(directory,""))[-length(unlist(strsplit(directory,"")))],collapse = "") } - if(include.gid==T){ + if(include.gid == TRUE){ rgdal::writeOGR(obj = spdf, dsn = directory, layer = paste(df$species[l],"_",df$gid[l],sep=""), driver = "ESRI Shapefile", - overwrite_layer = T) + overwrite_layer = TRUE) }else{ @@ -1243,7 +1290,7 @@ BIEN_ranges_species<-function(species, dsn = directory, layer = paste(df$species[l]), driver = "ESRI Shapefile", - overwrite_layer = T) + overwrite_layer = TRUE) } @@ -1281,7 +1328,7 @@ BIEN_ranges_species<-function(species, } - } #matched_names_only ==TRUE + } #matched_names_only == TRUE } #################################### @@ -1293,6 +1340,7 @@ BIEN_ranges_species<-function(species, #' @param directory The directory where range shapefiles will be stored. If NULL, a temporary directoray will be used. #' @param batch_size The number of ranges to download at once. #' @param return_directory Should the directory be returned? Default is TRUE +#' @param use_parallel Logical. Should batches be downloaded in parallel? If set to TRUE, AND if parallel and foreach are available, parallel processing of downloads will use n-1 clusters. #' @return Optionally, the directory to which the files were saved. #' @note This function may take a long time (hours) to run depending on the number of cores, download speed, etc. #' @examples \dontrun{ @@ -1306,7 +1354,8 @@ BIEN_ranges_species<-function(species, BIEN_ranges_species_bulk <- function(species = NULL, directory = NULL, batch_size = 1000, - return_directory = TRUE){ + return_directory = TRUE, + use_parallel = FALSE){ #Set species list and directory if NULL @@ -1321,17 +1370,20 @@ BIEN_ranges_species_bulk <- function(species = NULL, - if(nzchar(system.file(package = "doParallel")) & nzchar(system.file(package = "foreach")) ){ + if(nzchar(system.file(package = "doParallel")) & nzchar(system.file(package = "foreach")) & use_parallel){ #Download range maps cl <- parallel::makePSOCKcluster(parallel::detectCores()) - doParallel::registerDoParallel(cl = cl,cores = parallel::detectCores()) + doParallel::registerDoParallel(cl = cl, + cores = parallel::detectCores() - 1) foreach::foreach(i = 1:ceiling(length(species)/batch_size )) %dopar% - BIEN_ranges_species(species = species[(((i-1)*batch_size)+1):(i*batch_size)],directory = file.path(directory,i),matched = F) + BIEN_ranges_species(species = species[(((i-1)*batch_size)+1):(i*batch_size)], + directory = file.path(directory,i), + matched = FALSE) parallel::stopCluster(cl) rm(cl) @@ -1341,7 +1393,9 @@ BIEN_ranges_species_bulk <- function(species = NULL, for(i in 1:ceiling(length(species)/batch_size )){ - BIEN_ranges_species(species = species[(((i-1)*batch_size)+1):(i*batch_size)],directory = file.path(directory,i),matched = F) + BIEN_ranges_species(species = species[(((i-1)*batch_size)+1):(i*batch_size)], + directory = file.path(directory,i), + matched = FALSE) } @@ -1381,7 +1435,7 @@ BIEN_ranges_species_bulk <- function(species = NULL, #' #Plotting files #' plot(Abies_poly)#plots the range, but doesn't mean much without any reference #' map('world', fill = TRUE, col = "grey")#plots a world map (WGS84 projection), in grey -#' plot(Abies_poly,col="forest green",add=TRUE) #adds the range of Abies lasiocarpa to the map +#' plot(Abies_poly,col="forest green",add = TRUE) #adds the range of Abies lasiocarpa to the map #' #' #Getting data from the files (currently only species names) #' Abies_poly$Species#gives the species name associated with "Abies_poly"} @@ -1403,7 +1457,7 @@ BIEN_ranges_genus<-function(genus, #modify the genus list to make searching easier genus<-paste("(",genus,"_",")",sep = "") - if(match_names_only==FALSE){ + if(match_names_only == FALSE){ #record original working directory,change to specified directory if given if(is.null(directory)){ directory<-getwd() @@ -1434,10 +1488,10 @@ BIEN_ranges_genus<-function(genus, directory<-paste(unlist(strsplit(directory,""))[-length(unlist(strsplit(directory,"")))],collapse = "") } - if(include.gid==T){ - rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l],"_",df$gid[l],sep=""),driver = "ESRI Shapefile",overwrite_layer = T) + if(include.gid == TRUE){ + rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l],"_",df$gid[l],sep=""),driver = "ESRI Shapefile",overwrite_layer = TRUE) }else{ - rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l]),driver = "ESRI Shapefile",overwrite_layer = T) + rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l]),driver = "ESRI Shapefile",overwrite_layer = TRUE) } #save output @@ -1448,27 +1502,27 @@ BIEN_ranges_genus<-function(genus, #setwd(wd) #return wd to original #list matched species - if(matched==TRUE){ + if(matched == TRUE){ found<-as.data.frame(df$species) return(found) }#matched = true }#match names only if statement - if(match_names_only==TRUE){ + if(match_names_only == TRUE){ query <- paste("SELECT species FROM ranges WHERE species ~ '",paste(genus,collapse="|"),"' ORDER BY species ;",sep="") # create query to retrieve df <- .BIEN_sql(query, ...) - if(length(df)==0){ + if(length(df) == 0){ message("No species matched") }else{ found<-as.data.frame(df$species) return(found) } - } #matched_names_only ==TRUE + } #matched_names_only == TRUE } @@ -1490,16 +1544,16 @@ BIEN_ranges_genus<-function(genus, #' @family range functions #' @importFrom sp SpatialPolygonsDataFrame #' @export -BIEN_ranges_box<-function(min.lat, - max.lat, - min.long, - max.long, - directory = NULL, - species.names.only = FALSE, - return.species.list = TRUE , - crop.ranges = FALSE, - include.gid = FALSE, - ...){ +BIEN_ranges_box <- function(min.lat, + max.lat, + min.long, + max.long, + directory = NULL, + species.names.only = FALSE, + return.species.list = TRUE , + crop.ranges = FALSE, + include.gid = FALSE, + ...){ .is_num(min.lat) .is_num(max.lat) @@ -1509,7 +1563,7 @@ BIEN_ranges_box<-function(min.lat, .is_log(return.species.list) .is_log(species.names.only) - if(species.names.only==FALSE){ + if(species.names.only == FALSE){ #record original working directory,change to specified directory if given if(is.null(directory)){ @@ -1543,10 +1597,12 @@ BIEN_ranges_box<-function(min.lat, directory<-paste(unlist(strsplit(directory,""))[-length(unlist(strsplit(directory,"")))],collapse = "") } - if(include.gid==T){ - rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l],"_",df$gid[l],sep=""),driver = "ESRI Shapefile",overwrite_layer = T) + if(include.gid == TRUE){ + rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l],"_",df$gid[l],sep=""),driver = "ESRI Shapefile", + overwrite_layer = TRUE) }else{ - rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l]),driver = "ESRI Shapefile",overwrite_layer = T) + rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l]),driver = "ESRI Shapefile", + overwrite_layer = TRUE) } #save output @@ -1575,7 +1631,7 @@ BIEN_ranges_box<-function(min.lat, } - } #species.names.only ==TRUE + } #species.names.only == TRUE } ####################################### #'Download range maps that intersect the range of a given species. @@ -1650,10 +1706,12 @@ BIEN_ranges_intersect_species <- function(species, directory<-paste(unlist(strsplit(directory,""))[-length(unlist(strsplit(directory,"")))],collapse = "") } - if(include.gid == T){ - rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l],"_",df$gid[l],sep=""),driver = "ESRI Shapefile",overwrite_layer = T) + if(include.gid == TRUE){ + rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l],"_",df$gid[l],sep=""),driver = "ESRI Shapefile", + overwrite_layer = TRUE) }else{ - rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l]),driver = "ESRI Shapefile",overwrite_layer = T) + rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l]),driver = "ESRI Shapefile", + overwrite_layer = TRUE) } #save output @@ -1684,7 +1742,7 @@ BIEN_ranges_intersect_species <- function(species, } - } #species.names.only ==TRUE + } #species.names.only == TRUE } ####################################### @@ -1759,10 +1817,12 @@ BIEN_ranges_spatialpolygons<-function(spatialpolygons, directory<-paste(unlist(strsplit(directory,""))[-length(unlist(strsplit(directory,"")))],collapse = "") } - if(include.gid == T){ - rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l],"_",df$gid[l],sep=""),driver = "ESRI Shapefile",overwrite_layer = T) + if(include.gid == TRUE){ + rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l],"_",df$gid[l],sep=""),driver = "ESRI Shapefile", + overwrite_layer = TRUE) }else{ - rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l]),driver = "ESRI Shapefile",overwrite_layer = T) + rgdal::writeOGR(obj = spdf,dsn = directory,layer = paste(df$species[l]),driver = "ESRI Shapefile", + overwrite_layer = TRUE) } #save output @@ -1791,7 +1851,7 @@ BIEN_ranges_spatialpolygons<-function(spatialpolygons, } - } #species.names.only ==TRUE + } #species.names.only == TRUE } ####################################### @@ -1810,13 +1870,14 @@ BIEN_ranges_spatialpolygons<-function(spatialpolygons, #' #Plotting files #' plot(abies_maps)#plots the spatialpolygons, but doesn't mean much without any reference #' map('world', fill = TRUE, col = "grey")#plots a world map (WGS84 projection), in grey -#' plot(xanthium_strumarium,col="forest green",add=TRUE) #adds the range of X. strumarium -#' plot(abies_maps[1,], add = T, col ="light green")} +#' plot(xanthium_strumarium,col="forest green",add = TRUE) #adds the range of X. strumarium +#' plot(abies_maps[1,], add = TRUE, col ="light green")} #' @family range functions #' @importFrom rgeos readWKT #' @importFrom sp SpatialPolygonsDataFrame SpatialPolygons CRS #' @export -BIEN_ranges_load_species<-function(species, ...){ +BIEN_ranges_load_species <- function(species, + ...){ .is_char(species) @@ -1829,7 +1890,7 @@ BIEN_ranges_load_species<-function(species, ...){ # create query to retrieve df <- .BIEN_sql(query, ...) - if(length(df)==0){ + if(length(df) == 0){ message("No species matched") @@ -1902,7 +1963,9 @@ BIEN_ranges_shapefile_to_skinny <- function(directory, skinny_ranges_file = NULL){ - range_maps <- list.files(path = directory,pattern = ".shp",full.names = T,recursive = T) + range_maps <- list.files(path = directory,pattern = ".shp", + full.names = TRUE, + recursive = TRUE) skinny_occurrences <- NULL @@ -1911,10 +1974,10 @@ BIEN_ranges_shapefile_to_skinny <- function(directory, #print(i) map_i<-read_sf(i) map_i<-st_transform(x = map_i,crs = paste(raster@crs)) - raster_i<-fasterize(sf = map_i,raster = raster,fun = "any") + raster_i<-fasterize(sf = map_i,raster = raster, fun = "any") - if(length(which(getValues(raster_i)>0))>0){ - skinny_occurrences<-rbind(skinny_occurrences,cbind(map_i$Species,which(getValues(raster_i)>0))) + if(length(which(getValues(raster_i) > 0)) > 0){ + skinny_occurrences<-rbind(skinny_occurrences, cbind(map_i$Species, which(getValues(raster_i) > 0))) }#end if statement }#end i loop @@ -1961,7 +2024,8 @@ BIEN_ranges_shapefile_to_skinny <- function(directory, #' } #' @family range functions #' @export -BIEN_ranges_skinny_ranges_to_richness_raster<-function(skinny_ranges, raster){ +BIEN_ranges_skinny_ranges_to_richness_raster <- function(skinny_ranges, + raster){ #Create empty output raster output_raster <- raster @@ -1994,11 +2058,11 @@ BIEN_ranges_skinny_ranges_to_richness_raster<-function(skinny_ranges, raster){ #' BIEN_trait_species(species_vector)} #' @family trait functions #' @export -BIEN_trait_species<-function(species, - all.taxonomy = FALSE, - political.boundaries = FALSE, - source.citation = FALSE, - ...){ +BIEN_trait_species <- function(species, + all.taxonomy = FALSE, + political.boundaries = FALSE, + source.citation = FALSE, + ...){ .is_char(species) .is_log(all.taxonomy) @@ -2033,9 +2097,9 @@ BIEN_trait_species<-function(species, #' BIEN_trait_mean(species=c("Poa annua","Juncus trifidus"),trait="leaf dry mass per leaf fresh mass") } #' @family trait functions #' @export -BIEN_trait_mean<-function(species, - trait, - ...){ +BIEN_trait_mean <- function(species, + trait, + ...){ #first, get taxonomic info for the species @@ -2131,11 +2195,10 @@ BIEN_trait_mean<-function(species, #' BIEN_trait_trait(trait_vector)} #' @family trait functions #' @export -BIEN_trait_trait<-function(trait, - all.taxonomy = FALSE, - political.boundaries = FALSE, - source.citation = FALSE, - ...){ +BIEN_trait_trait <- function(trait, + all.taxonomy = FALSE, + political.boundaries = FALSE, + source.citation = FALSE,...){ .is_char(trait) .is_log(all.taxonomy) @@ -2173,7 +2236,12 @@ BIEN_trait_trait<-function(trait, #' BIEN_trait_traitbyspecies(trait=trait_vector,species=species_vector)} #' @family trait functions #' @export -BIEN_trait_traitbyspecies <- function(species, trait, all.taxonomy = FALSE, political.boundaries = FALSE,source.citation =F, ...){ +BIEN_trait_traitbyspecies <- function(species, + trait, + all.taxonomy = FALSE, + political.boundaries = FALSE, + source.citation = FALSE, + ...){ .is_char(species) .is_char(trait) .is_log(all.taxonomy) @@ -2181,9 +2249,9 @@ BIEN_trait_traitbyspecies <- function(species, trait, all.taxonomy = FALSE, poli .is_log(source.citation) # set the query - taxonomy_<-.taxonomy_check_traits(all.taxonomy) - political_<-.political_check_traits(political.boundaries) - source_<-.source_check_traits(source.citation) + taxonomy_ <- .taxonomy_check_traits(all.taxonomy) + political_ <- .political_check_traits(political.boundaries) + source_ <- .source_check_traits(source.citation) query <- paste("SELECT scrubbed_species_binomial, trait_name, trait_value, unit, method, latitude, longitude, elevation_m, url_source",source_$select ,", project_pi, project_pi_contact", @@ -2212,7 +2280,13 @@ BIEN_trait_traitbyspecies <- function(species, trait, all.taxonomy = FALSE, poli #' BIEN_trait_traitbygenus(trait=trait_vector,genus=genus_vector)} #' @family trait functions #' @export -BIEN_trait_traitbygenus <- function(genus, trait, all.taxonomy = FALSE, political.boundaries = FALSE, source.citation =F, ...){ +BIEN_trait_traitbygenus <- function(genus, + trait, + all.taxonomy = FALSE, + political.boundaries = FALSE, + source.citation = FALSE, + ...){ + .is_char(genus) .is_char(trait) .is_log(all.taxonomy) @@ -2246,12 +2320,18 @@ BIEN_trait_traitbygenus <- function(genus, trait, all.taxonomy = FALSE, politica #' @return A dataframe of all data matching the specified trait(s) and family/families. #' @examples \dontrun{ #' BIEN_trait_traitbyfamily(trait = "whole plant height", family = "Poaceae") -#' trait_vector<-c("whole plant height", "leaf fresh mass") -#' family_vector<-c("Orchidaceae","Poaceae") -#' BIEN_trait_traitbyfamily(trait=trait_vector,family=family_vector)} +#' trait_vector <- c("whole plant height", "leaf fresh mass") +#' family_vector < -c("Orchidaceae","Poaceae") +#' BIEN_trait_traitbyfamily(trait = trait_vector, family = family_vector)} #' @family trait functions #' @export -BIEN_trait_traitbyfamily<-function(family, trait, all.taxonomy = FALSE, political.boundaries = FALSE,source.citation =F, ...){ +BIEN_trait_traitbyfamily <- function(family, + trait, + all.taxonomy = FALSE, + political.boundaries = FALSE, + source.citation = FALSE, + ...){ + .is_char(family) .is_char(trait) .is_log(all.taxonomy) @@ -2284,11 +2364,16 @@ BIEN_trait_traitbyfamily<-function(family, trait, all.taxonomy = FALSE, politica #' @return A dataframe of all data matching the specified genera. #' @examples \dontrun{ #' BIEN_trait_genus("Acer") -#' genus_vector<-c("Acer","Abies") +#' genus_vector <- c("Acer","Abies") #' BIEN_trait_genus(genus_vector)} #' @family trait funcitons #' @export -BIEN_trait_genus<-function(genus, all.taxonomy = FALSE, political.boundaries = FALSE,source.citation =F, ...){ +BIEN_trait_genus <- function(genus, + all.taxonomy = FALSE, + political.boundaries = FALSE, + source.citation = FALSE, + ...){ + .is_char(genus) .is_log(all.taxonomy) .is_log(political.boundaries) @@ -2323,7 +2408,12 @@ BIEN_trait_genus<-function(genus, all.taxonomy = FALSE, political.boundaries = F #' BIEN_trait_family(family_vector)} #' @family trait functions #' @export -BIEN_trait_family<-function(family, all.taxonomy = FALSE, political.boundaries = FALSE,source.citation =F, ...){ +BIEN_trait_family <- function(family, + all.taxonomy = FALSE, + political.boundaries = FALSE, + source.citation = FALSE, + ...){ + .is_char(family) .is_log(all.taxonomy) .is_log(political.boundaries) @@ -2378,7 +2468,12 @@ BIEN_trait_list <- function( ...){ #' BIEN_trait_country(country="South Africa",trait="whole plant growth form")} #' @family trait functions #' @export -BIEN_trait_country <- function(country, trait.name=NULL, all.taxonomy = FALSE, political.boundaries = TRUE,source.citation =F, ...){ +BIEN_trait_country <- function(country, + trait.name = NULL, + all.taxonomy = FALSE, + political.boundaries = TRUE, + source.citation = FALSE, + ...){ .is_char(country) .is_log(all.taxonomy) @@ -2419,7 +2514,8 @@ BIEN_trait_country <- function(country, trait.name=NULL, all.taxonomy = FALSE, p #' occurrence_counts<-BIEN_occurrence_records_per_species()} #' @family occurrence functions #' @export -BIEN_occurrence_records_per_species <- function(species=NULL, ...){ +BIEN_occurrence_records_per_species <- function(species = NULL, + ...){ if(is.null(species)){ # set the query @@ -2451,7 +2547,8 @@ BIEN_occurrence_records_per_species <- function(species=NULL, ...){ #' trait_observation_counts<-BIEN_trait_traits_per_species()} #' @family trait functions #' @export -BIEN_trait_traits_per_species<-function(species = NULL, ...){ +BIEN_trait_traits_per_species <- function(species = NULL, + ...){ if(!is.null(species)){ @@ -2488,16 +2585,16 @@ BIEN_trait_traits_per_species<-function(species = NULL, ...){ #' BIEN_plot_datasource("SALVIAS")} #' @family plot functions #' @export -BIEN_plot_datasource<-function(datasource, - cultivated = FALSE, - new.world = NULL, - all.taxonomy = FALSE, - native.status = FALSE, - natives.only = TRUE, - political.boundaries = FALSE, - collection.info = FALSE, - all.metadata = FALSE, - ...){ +BIEN_plot_datasource <- function(datasource, + cultivated = FALSE, + new.world = NULL, + all.taxonomy = FALSE, + native.status = FALSE, + natives.only = TRUE, + political.boundaries = FALSE, + collection.info = FALSE, + all.metadata = FALSE, + ...){ .is_log(cultivated) .is_log_or_null(new.world) @@ -2510,14 +2607,14 @@ BIEN_plot_datasource<-function(datasource, .is_log(all.metadata) #set conditions for query - cultivated_<-.cultivated_check_plot(cultivated) - newworld_<-.newworld_check_plot(new.world) - taxonomy_<-.taxonomy_check_plot(all.taxonomy) - native_<-.native_check_plot(native.status) - natives_<-.natives_check_plot(natives.only) - political_<-.political_check_plot(political.boundaries) - collection_<-.collection_check_plot(collection.info) - md_<-.md_check_plot(all.metadata) + cultivated_ <- .cultivated_check_plot(cultivated) + newworld_ <- .newworld_check_plot(new.world) + taxonomy_ <- .taxonomy_check_plot(all.taxonomy) + native_ <- .native_check_plot(native.status) + natives_ <- .natives_check_plot(natives.only) + political_ <- .political_check_plot(political.boundaries) + collection_ <- .collection_check_plot(collection.info) + md_ <- .md_check_plot(all.metadata) # set the query query <- paste("SELECT view_full_occurrence_individual.plot_name,view_full_occurrence_individual.subplot, view_full_occurrence_individual.elevation_m, @@ -2600,18 +2697,18 @@ BIEN_plot_country <- function(country = NULL, if(is.null(country)& is.null(country.code)) {stop("Please supply either a country name or 2-digit ISO code")} #set conditions for query - cultivated_<-.cultivated_check_plot(cultivated) - newworld_<-.newworld_check_plot(new.world) - taxonomy_<-.taxonomy_check_plot(all.taxonomy) - native_<-.native_check_plot(native.status) - natives_<-.natives_check_plot(natives.only) - collection_<-.collection_check_plot(collection.info) - md_<-.md_check_plot(all.metadata) + cultivated_ <- .cultivated_check_plot(cultivated) + newworld_ <- .newworld_check_plot(new.world) + taxonomy_ <- .taxonomy_check_plot(all.taxonomy) + native_ <- .native_check_plot(native.status) + natives_ <- .natives_check_plot(natives.only) + collection_ <- .collection_check_plot(collection.info) + md_ <- .md_check_plot(all.metadata) if(!political.boundaries){ - political_select<-"view_full_occurrence_individual.country," + political_select <- "view_full_occurrence_individual.country," }else{ - political_select<-"view_full_occurrence_individual.country,view_full_occurrence_individual.state_province,view_full_occurrence_individual.county,view_full_occurrence_individual.locality," + political_select <- "view_full_occurrence_individual.country,view_full_occurrence_individual.state_province,view_full_occurrence_individual.county,view_full_occurrence_individual.locality," } # set the query @@ -2676,7 +2773,20 @@ BIEN_plot_country <- function(country = NULL, #' BIEN_plot_state(country="United States",state= c("Colorado","California"))} #' @family plot functions #' @export -BIEN_plot_state <- function(country=NULL,state=NULL,country.code=NULL,state.code=NULL,cultivated=FALSE,new.world=NULL,all.taxonomy=FALSE,native.status=FALSE,natives.only=TRUE,political.boundaries=TRUE,collection.info=F,all.metadata=FALSE, ...){ +BIEN_plot_state <- function(country = NULL, + state = NULL, + country.code = NULL, + state.code = NULL, + cultivated = FALSE, + new.world = NULL, + all.taxonomy = FALSE, + native.status = FALSE, + natives.only = TRUE, + political.boundaries = TRUE, + collection.info = FALSE, + all.metadata = FALSE, + ...){ + .is_char(country) .is_log(cultivated) .is_log_or_null(new.world) @@ -2807,7 +2917,17 @@ BIEN_plot_state <- function(country=NULL,state=NULL,country.code=NULL,state.code #' @family plot functions #' @importFrom rgeos writeWKT #' @export -BIEN_plot_spatialpolygons <- function(spatialpolygons,cultivated=FALSE,new.world=NULL,all.taxonomy=FALSE,native.status=FALSE,natives.only=TRUE,political.boundaries=TRUE,collection.info=F,all.metadata=FALSE, ...){ +BIEN_plot_spatialpolygons <- function(spatialpolygons, + cultivated = FALSE, + new.world = NULL, + all.taxonomy = FALSE, + native.status = FALSE, + natives.only = TRUE, + political.boundaries = TRUE, + collection.info = FALSE, + all.metadata = FALSE, + ...){ + .is_log(cultivated) .is_log_or_null(new.world) .is_log(all.taxonomy) @@ -2958,7 +3078,7 @@ BIEN_plot_name <- function(plot.name, native.status = FALSE, natives.only = TRUE, political.boundaries = FALSE, - collection.info = F, + collection.info = FALSE, all.metadata = FALSE, ...){ @@ -3108,7 +3228,8 @@ BIEN_plot_metadata <- function( ...){ #' BIEN_taxonomy_species(species_vector)} #' @family taxonomy functions #' @export -BIEN_taxonomy_species<-function(species, ...){ +BIEN_taxonomy_species <- function(species, + ...){ .is_char(species) @@ -3140,7 +3261,8 @@ BIEN_taxonomy_species<-function(species, ...){ #' BIEN_taxonomy_genus(genus_vector)} #' @family taxonomy functions #' @export -BIEN_taxonomy_genus<-function(genus, ...){ +BIEN_taxonomy_genus <- function(genus, + ...){ .is_char(genus) @@ -3172,7 +3294,8 @@ BIEN_taxonomy_genus<-function(genus, ...){ #' BIEN_taxonomy_family(family_vector)} #' @family taxonomy functions #' @export -BIEN_taxonomy_family<-function(family, ...){ +BIEN_taxonomy_family <- function(family, + ...){ .is_char(family) @@ -3296,22 +3419,22 @@ BIEN_phylogeny_conservative <- function(...){ #' phylogeny<-BIEN_phylogeny_conservative() #' #'phylogeny<-drop.tip(phy = phylogeny,tip = 101:length(phylogeny$tip.label)) -#'plot.phylo(x = phylogeny,show.tip.label = F) +#'plot.phylo(x = phylogeny,show.tip.label = FALSE) #' -#'fam_nodes<-BIEN_phylogeny_label_nodes(phylogeny = phylogeny,family = T) -#'plot.phylo(x = fam_nodes,show.tip.label = F,show.node.label = T) +#'fam_nodes<-BIEN_phylogeny_label_nodes(phylogeny = phylogeny,family = TRUE) +#'plot.phylo(x = fam_nodes,show.tip.label = FALSE, show.node.label = TRUE) #' -#'gen_nodes<-BIEN_phylogeny_label_nodes(phylogeny = phylogeny,family = F,genus = T) -#'plot.phylo(x = gen_nodes,show.tip.label = F,show.node.label = T) +#'gen_nodes<-BIEN_phylogeny_label_nodes(phylogeny = phylogeny, family = FALSE, genus = TRUE) +#'plot.phylo(x = gen_nodes, show.tip.label = FALSE, show.node.label = TRUE) #' -#'other_taxa<-as.data.frame(matrix(nrow = 10,ncol = 2)) +#'other_taxa <- as.data.frame(matrix(nrow = 10,ncol = 2)) #'colnames(other_taxa)<-c("taxon","species") #'other_taxa$taxon[1:5]<-"A" #Randomly assign a few species to taxon A #'other_taxa$taxon[6:10]<-"B" #Randomly assign a few species to taxon B #'tax_nodes <- #' BIEN_phylogeny_label_nodes(phylogeny = phylogeny, -#' family = F,genus = F,other_taxa = other_taxa) -#'plot.phylo(x = tax_nodes,show.tip.label = F,show.node.label = T)} +#' family = FALSE, genus = FALSE, other_taxa = other_taxa) +#'plot.phylo(x = tax_nodes,show.tip.label = FALSE,show.node.label = TRUE)} #' @family phylogeny functions #' @importFrom ape getMRCA #' @export @@ -3563,7 +3686,7 @@ BIEN_metadata_citation <- function(dataframe = NULL, citation[[2]]<-gsub(citation[[2]],pattern = "note", replacement = "\nnote") citation[[2]]<-iconv(citation[[2]],to="ASCII//TRANSLIT") citation[[2]]<-gsub(citation[[2]],pattern = '\n}\"', replacement = '\n}') - citation[[2]]<-gsub(citation[[2]],pattern = '\"\\\nurl', replacement = '\"\\url',fixed = T) + citation[[2]]<-gsub(citation[[2]],pattern = '\"\\\nurl', replacement = '\"\\url', fixed = TRUE) if(length(unique(sources$source_name[which(sources$is_herbarium==1)]))>0){ citation[[3]]<-paste("We acknowledge the herbaria that contributed data to this work: ",paste(unique(sources$source_name[which(sources$is_herbarium==1)]),collapse = ", "),".",collapse = "",sep="") @@ -3696,7 +3819,7 @@ BIEN_metadata_citation <- function(dataframe = NULL, citation[[2]]<-gsub(citation[[2]],pattern = "note", replacement = "\nnote") citation[[2]]<-iconv(citation[[2]],to="ASCII//TRANSLIT") citation[[2]]<-gsub(citation[[2]],pattern = '\n}\"', replacement = '\n}') - citation[[2]]<-gsub(citation[[2]],pattern = '\"\\\nurl', replacement = '\"\\url',fixed = T) + citation[[2]]<-gsub(citation[[2]],pattern = '\"\\\nurl', replacement = '\"\\url', fixed = TRUE) citation[[3]]<-data.frame() ack_trait_sources<-trait.sources[which(trait.sources$access=='public (notify the PIs)'),] ack_trait_sources<-ack_trait_sources[c('project_pi','project_pi_contact','access','source_citation','citation_bibtex')] @@ -3791,11 +3914,11 @@ BIEN_metadata_list_political_names <- function(...){ #' BIEN_stem_species("Abies amabilis") #' species_vector<-c("Abies amabilis", "Acer nigrum") #' BIEN_stem_species(species_vector) -#' BIEN_stem_species(species_vector,all.taxonomy=TRUE)} +#' BIEN_stem_species(species_vector,all.taxonomy = TRUE)} #' @family stem functions #' @export BIEN_stem_species <- function(species, - cultivated =FALSE, + cultivated = FALSE, new.world = NULL, all.taxonomy = FALSE, native.status = FALSE, @@ -3861,7 +3984,7 @@ BIEN_stem_species <- function(species, #' BIEN_stem_family(family = "Marantaceae") #' family_vector<-c("Marantaceae", "Buxaceae") #' BIEN_stem_family(family = family_vector) -#' BIEN_stem_family(family = family_vector, all.taxonomy=TRUE, native.status=T)} +#' BIEN_stem_family(family = family_vector, all.taxonomy = TRUE, native.status = TRUE)} #' @family stem functions #' @export BIEN_stem_family <- function(family, @@ -3930,7 +4053,7 @@ BIEN_stem_family <- function(family, #' BIEN_stem_genus(genus = "Tovomita") #' genus_vector<-c("Tovomita", "Myrcia") #' BIEN_stem_genus(genus = genus_vector) -#' BIEN_stem_genus(genus = genus_vector, all.taxonomy=TRUE)} +#' BIEN_stem_genus(genus = genus_vector, all.taxonomy = TRUE)} #' @family stem functions #' @export BIEN_stem_genus <- function(genus, diff --git a/R/BIEN_info.R b/R/BIEN_info.R index 4072fb5..1da7032 100644 --- a/R/BIEN_info.R +++ b/R/BIEN_info.R @@ -14,14 +14,14 @@ NULL ################### -.onAttach <- function(libname,pkgname) { +.onAttach <- function(libname, pkgname) { packageStartupMessage('Type vignette("BIEN") or vignette("BIEN_tutorial") to get started') - suppressWarnings(x <- try(readLines("https://raw.githubusercontent.com/bmaitner/RBIEN/master/NOTES", warn = F), silent = T)) + suppressWarnings(x <- try(readLines("https://raw.githubusercontent.com/bmaitner/RBIEN/master/NOTES", warn = FALSE), silent = TRUE)) if(class(x)=="character"){ if(length(x) != 0){ - packageStartupMessage(x, appendLF = T) + packageStartupMessage(x, appendLF = TRUE) } diff --git a/R/BIEN_sql.R b/R/BIEN_sql.R index 39d0fd7..5a428f6 100644 --- a/R/BIEN_sql.R +++ b/R/BIEN_sql.R @@ -52,7 +52,7 @@ if(print.query){ query <- gsub(pattern = "\n",replacement = "",query) - query <- gsub("(?<=[\\s])\\s*|^\\s+|\\s+$", "", query, perl=TRUE) + query <- gsub("(?<=[\\s])\\s*|^\\s+|\\s+$", "", query, perl = TRUE) print(query) } @@ -78,7 +78,10 @@ if(!is.null(view_full_occurrence_individual)){ #query<-gsub(pattern = "\\",replacement = view_full_occurrence_individual,x = query)} - query <- gsub(pattern = "(?",replacement = view_full_occurrence_individual,x = query)} - query <- gsub(pattern = "(?",replacement = view_full_occurrence_individual,x = query)} - query <- gsub(pattern = "(?",replacement = phylogeny,x = query) + query <- gsub(pattern = "\\", + replacement = phylogeny, + x = query) } if(!is.null(bien_metadata)){ - query <- gsub(pattern = "\\",replacement = bien_metadata,x = query) + query <- gsub(pattern = "\\", + replacement = bien_metadata, + x = query) } if(!is.null(datasource)){ - query <- gsub(pattern = "(?<=\\s)datasource(?=\\s)",replacement = datasource,x = query,perl = T) + query <- gsub(pattern = "(?<=\\s)datasource(?=\\s)", + replacement = datasource, + x = query, + perl = TRUE) } if(!is.null(centroid)){ - query <- gsub(pattern = "(?<=\\s)centroid(?=\\s)",replacement = datasource,x = query,perl = T) + query <- gsub(pattern = "(?<=\\s)centroid(?=\\s)", + replacement = datasource, + x = query, + perl = TRUE) } if(!is.null(limit)){ - query <- gsub(pattern = " ;",replacement = paste(" LIMIT ",limit,";"),x = query) + query <- gsub(pattern = " ;", + replacement = paste(" LIMIT ",limit,";"), + x = query) } diff --git a/R/internals.R b/R/internals.R index 5753678..966f307 100644 --- a/R/internals.R +++ b/R/internals.R @@ -7,16 +7,21 @@ #'Helper function to set query components. #' @keywords internal .cultivated_check<-function(cultivated){ + if(!cultivated){ - query<-"AND (is_cultivated_observation = 0 OR is_cultivated_observation IS NULL) AND is_location_cultivated IS NULL" - select<-"" + + query <- "AND (is_cultivated_observation = 0 OR is_cultivated_observation IS NULL) AND is_location_cultivated IS NULL" + select <- "" + }else{ - query<-"" - select<-",is_cultivated_observation,is_cultivated_in_region, is_location_cultivated" + + query <- "" + select <- ",is_cultivated_observation,is_cultivated_in_region, is_location_cultivated" + } - output<-as.data.frame(cbind(query,select),stringsAsFactors = F) - colnames(output)<-c("query","select") + output <- as.data.frame(cbind(query,select), stringsAsFactors = FALSE) + colnames(output) <- c("query","select") return(output) @@ -28,30 +33,30 @@ #' #'Helper function to set query components. #' @keywords internal -.newworld_check<-function(new.world){ +.newworld_check <- function(new.world){ if(is.null(new.world)){ - query<-"" - select<-"" - output<-as.data.frame(cbind(query,select),stringsAsFactors = F) - colnames(output)<-c("query","select") + query <- "" + select <- "" + output <- as.data.frame(cbind(query,select),stringsAsFactors = FALSE) + colnames(output) <- c("query", "select") return(output) } if(!new.world){ - query<-"AND is_new_world = 0 " - select<-", is_new_world"} + query <- "AND is_new_world = 0 " + select <- ", is_new_world"} if(new.world){ - query<-"AND is_new_world = 1 " - select<-", is_new_world"} + query <- "AND is_new_world = 1 " + select <- ", is_new_world"} - output<-as.data.frame(cbind(query,select),stringsAsFactors = F) - colnames(output)<-c("query","select") + output <- as.data.frame(cbind(query,select), stringsAsFactors = FALSE) + colnames(output) <- c("query", "select") return(output) @@ -65,16 +70,21 @@ #'Helper function to set query components. #' @keywords internal .geovalid_check<-function(only.geovalid){ + if(!only.geovalid){ - query<-"" - select<-",is_geovalid" + + query <- "" + select <- ",is_geovalid" + }else{ - query<-"AND is_geovalid = 1" - select<-"" + + query <- "AND is_geovalid = 1" + select <- "" + } - output<-as.data.frame(cbind(query,select),stringsAsFactors = F) - colnames(output)<-c("query","select") + output <- as.data.frame(cbind(query,select), stringsAsFactors = FALSE) + colnames(output) <- c("query", "select") return(output) @@ -88,15 +98,20 @@ #' #'Helper function to set query components. #' @keywords internal -.taxonomy_check<-function(all.taxonomy){ +.taxonomy_check <- function(all.taxonomy){ + if(!all.taxonomy){ - select<-"" + + select <- "" + }else{ - select<-", verbatim_family,verbatim_scientific_name,family_matched,name_matched,name_matched_author,higher_plant_group,scrubbed_taxonomic_status,scrubbed_family,scrubbed_author" + + select <- ", verbatim_family,verbatim_scientific_name,family_matched,name_matched,name_matched_author,higher_plant_group,scrubbed_taxonomic_status,scrubbed_family,scrubbed_author" + } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) @@ -109,15 +124,15 @@ #' #'Helper function to set query components. #' @keywords internal -.native_check<-function(native.status){ +.native_check <- function(native.status){ if(!native.status){ - select<-"" + select <- "" }else{ - select<-",native_status, native_status_reason,native_status_sources,is_introduced,native_status_country,native_status_state_province,native_status_county_parish" + select <- ",native_status, native_status_reason,native_status_sources,is_introduced,native_status_country,native_status_state_province,native_status_county_parish" } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) @@ -128,17 +143,17 @@ #' #'Helper function to set query components. #' @keywords internal -.observation_check<-function(observation.type){ +.observation_check <- function(observation.type){ if(!observation.type){ - query<-"AND observation_type IN ('plot','specimen','literature','checklist')" - select<-"" + query <- "AND observation_type IN ('plot','specimen','literature','checklist')" + select <- "" }else{ - query<-"" - select<-",observation_type" + query <- "" + select <- ",observation_type" } - output<-as.data.frame(cbind(query,select),stringsAsFactors = F) - colnames(output)<-c("query","select") + output <- as.data.frame(cbind(query,select), stringsAsFactors = FALSE) + colnames(output) <- c("query","select") return(output) @@ -150,16 +165,16 @@ #' #'Helper function to set query components. #' @keywords internal -.political_check<-function(political.boundaries){ +.political_check <- function(political.boundaries){ if(!political.boundaries){ - select<-"" + select <- "" }else{ - select<-", country,state_province,county,locality,elevation_m" + select <- ", country,state_province,county,locality,elevation_m" } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select),stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) @@ -171,15 +186,15 @@ #' #'Helper function to set query components. #' @keywords internal -.natives_check<-function(natives.only){ +.natives_check <- function(natives.only){ if(!natives.only){ - query<-"" + query <- "" }else{ - query<-"AND (is_introduced=0 OR is_introduced IS NULL) " + query <- "AND (is_introduced=0 OR is_introduced IS NULL) " } - output<-as.data.frame(cbind(query),stringsAsFactors = F) - colnames(output)<-c("query") + output <- as.data.frame(cbind(query), stringsAsFactors = FALSE) + colnames(output) <- c("query") return(output) @@ -190,15 +205,15 @@ #' #'Helper function to set query components. #' @keywords internal -.collection_check<-function(collection.info){ +.collection_check <- function(collection.info){ if(!collection.info){ - select<-"" + select <- "" }else{ - select<-",catalog_number, recorded_by, record_number, date_collected, identified_by, date_identified, identification_remarks " + select <- ",catalog_number, recorded_by, record_number, date_collected, identified_by, date_identified, identification_remarks " } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) @@ -212,16 +227,20 @@ #' #'Helper function to set query components. #' @keywords internal -.political_check_traits<-function(political.boundaries){ +.political_check_traits <- function(political.boundaries){ + if(political.boundaries){ - select <- "region, country, state_province, locality_description" + + select <- "region, country, state_province, locality_description" + }else{ + select <- "" } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select),stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) @@ -232,21 +251,23 @@ if(political.boundaries){ #' #'Helper function to set query components. #' @keywords internal -.taxonomy_check_traits<-function(all.taxonomy){ +.taxonomy_check_traits <- function(all.taxonomy){ if(all.taxonomy){ + select <- "verbatim_family, verbatim_scientific_name, name_submitted, family_matched, name_matched, name_matched_author, higher_plant_group, tnrs_warning, matched_taxonomic_status, scrubbed_taxonomic_status, scrubbed_family, scrubbed_genus, scrubbed_specific_epithet, scrubbed_taxon_name_no_author, scrubbed_taxon_canonical, scrubbed_author, scrubbed_taxon_name_with_author, scrubbed_species_binomial_with_morphospecies" }else{ + select <- "" } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) @@ -257,18 +278,20 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.source_check_traits<-function(source.citation){ +.source_check_traits <- function(source.citation){ if(source.citation){ + select <- ",source_citation" }else{ + select <- "" } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) @@ -285,16 +308,16 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.cultivated_check_plot<-function(cultivated){ +.cultivated_check_plot <- function(cultivated){ if(!cultivated){ - query<-"AND (view_full_occurrence_individual.is_cultivated_observation = 0 OR view_full_occurrence_individual.is_cultivated_observation IS NULL) AND view_full_occurrence_individual.is_location_cultivated IS NULL" - select<-"" + query <- "AND (view_full_occurrence_individual.is_cultivated_observation = 0 OR view_full_occurrence_individual.is_cultivated_observation IS NULL) AND view_full_occurrence_individual.is_location_cultivated IS NULL" + select <- "" }else{ - query<-"" - select<-",view_full_occurrence_individual.is_cultivated_observation,view_full_occurrence_individual.is_cultivated_in_region,view_full_occurrence_individual.is_location_cultivated" + query <- "" + select <- ",view_full_occurrence_individual.is_cultivated_observation,view_full_occurrence_individual.is_cultivated_in_region,view_full_occurrence_individual.is_location_cultivated" } - output<-as.data.frame(cbind(query,select),stringsAsFactors = F) - colnames(output)<-c("query","select") + output <- as.data.frame(cbind(query, select), stringsAsFactors = FALSE) + colnames(output) <- c("query","select") return(output) @@ -309,27 +332,29 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.newworld_check_plot<-function(new.world){ +.newworld_check_plot <- function(new.world){ if(is.null(new.world)){ - query<-"" - select<-"" - output<-as.data.frame(cbind(query,select),stringsAsFactors = F) - colnames(output)<-c("query","select") - return(output) + + query <- "" + select <- "" + output <- as.data.frame(cbind(query,select),stringsAsFactors = FALSE) + colnames(output) <- c("query","select") + return(output) } if(!new.world){ - query<-"AND view_full_occurrence_individual.is_new_world = 0 " - select<-",view_full_occurrence_individual.is_new_world"} + + query <- "AND view_full_occurrence_individual.is_new_world = 0 " + select <- ",view_full_occurrence_individual.is_new_world"} if(new.world){ - query<-"AND view_full_occurrence_individual.is_new_world = 1 " - select<-",view_full_occurrence_individual.is_new_world"} + query <- "AND view_full_occurrence_individual.is_new_world = 1 " + select <- ",view_full_occurrence_individual.is_new_world"} - output<-as.data.frame(cbind(query,select),stringsAsFactors = F) - colnames(output)<-c("query","select") + output <- as.data.frame(cbind(query,select),stringsAsFactors = FALSE) + colnames(output) <- c("query","select") return(output) @@ -344,15 +369,20 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.taxonomy_check_plot<-function(all.taxonomy){ +.taxonomy_check_plot <- function(all.taxonomy){ if(!all.taxonomy){ - select<-"" + + select <- "" + }else{ - select<-",view_full_occurrence_individual.verbatim_family,view_full_occurrence_individual.verbatim_scientific_name,view_full_occurrence_individual.family_matched,view_full_occurrence_individual.name_matched,view_full_occurrence_individual.name_matched_author,view_full_occurrence_individual.higher_plant_group,view_full_occurrence_individual.scrubbed_taxonomic_status,view_full_occurrence_individual.scrubbed_family,view_full_occurrence_individual.scrubbed_author" + + select <- ",view_full_occurrence_individual.verbatim_family,view_full_occurrence_individual.verbatim_scientific_name,view_full_occurrence_individual.family_matched,view_full_occurrence_individual.name_matched,view_full_occurrence_individual.name_matched_author,view_full_occurrence_individual.higher_plant_group,view_full_occurrence_individual.scrubbed_taxonomic_status,view_full_occurrence_individual.scrubbed_family,view_full_occurrence_individual.scrubbed_author" + } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) @@ -365,16 +395,16 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.native_check_plot<-function(native.status){ +.native_check_plot <- function(native.status){ if(!native.status){ - select<-"" + select <- "" }else{ - select<-",view_full_occurrence_individual.native_status,view_full_occurrence_individual.native_status_reason,view_full_occurrence_individual.native_status_sources,view_full_occurrence_individual.is_introduced,view_full_occurrence_individual.native_status_country,view_full_occurrence_individual.native_status_state_province,view_full_occurrence_individual.native_status_county_parish" + select <- ",view_full_occurrence_individual.native_status,view_full_occurrence_individual.native_status_reason,view_full_occurrence_individual.native_status_sources,view_full_occurrence_individual.is_introduced,view_full_occurrence_individual.native_status_country,view_full_occurrence_individual.native_status_state_province,view_full_occurrence_individual.native_status_county_parish" } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) @@ -387,16 +417,16 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.natives_check_plot<-function(natives.only){ +.natives_check_plot <- function(natives.only){ if(!natives.only){ - query<-"" + query <- "" }else{ - query<-"AND (view_full_occurrence_individual.is_introduced=0 OR view_full_occurrence_individual.is_introduced IS NULL) " + query <- "AND (view_full_occurrence_individual.is_introduced=0 OR view_full_occurrence_individual.is_introduced IS NULL) " } - output<-as.data.frame(cbind(query),stringsAsFactors = F) - colnames(output)<-c("query") + output <- as.data.frame(cbind(query), stringsAsFactors = FALSE) + colnames(output) <- c("query") return(output) @@ -411,16 +441,16 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.political_check_plot<-function(political.boundaries){ +.political_check_plot <- function(political.boundaries){ if(!political.boundaries){ - select<-"" + select <- "" }else{ - select<-",view_full_occurrence_individual.country,view_full_occurrence_individual.state_province,view_full_occurrence_individual.county,view_full_occurrence_individual.locality" + select <- ",view_full_occurrence_individual.country,view_full_occurrence_individual.state_province,view_full_occurrence_individual.county,view_full_occurrence_individual.locality" } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) @@ -433,16 +463,16 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.collection_check_plot<-function(collection.info){ +.collection_check_plot <- function(collection.info){ if(!collection.info){ - select<-"" + select <- "" }else{ - select<-",view_full_occurrence_individual.catalog_number, view_full_occurrence_individual.recorded_by, view_full_occurrence_individual.record_number, view_full_occurrence_individual.date_collected, view_full_occurrence_individual.identified_by, view_full_occurrence_individual.date_identified, view_full_occurrence_individual.identification_remarks " + select <- ",view_full_occurrence_individual.catalog_number, view_full_occurrence_individual.recorded_by, view_full_occurrence_individual.record_number, view_full_occurrence_individual.date_collected, view_full_occurrence_individual.identified_by, view_full_occurrence_individual.date_identified, view_full_occurrence_individual.identification_remarks " } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select),stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) @@ -455,18 +485,18 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.md_check_plot<-function(all.metadata){ +.md_check_plot <- function(all.metadata){ if(!all.metadata){ - select<-"" + select <- "" }else{ - select<-",plot_metadata.coord_uncertainty_m,plot_metadata.methodology_reference,plot_metadata.methodology_description,growth_forms_included_all, growth_forms_included_trees, growth_forms_included_shrubs, growth_forms_included_lianas, + select <- ",plot_metadata.coord_uncertainty_m,plot_metadata.methodology_reference,plot_metadata.methodology_description,growth_forms_included_all, growth_forms_included_trees, growth_forms_included_shrubs, growth_forms_included_lianas, growth_forms_included_herbs, growth_forms_included_epiphytes, growth_forms_included_notes, taxa_included_all, taxa_included_seed_plants, taxa_included_ferns_lycophytes, taxa_included_bryophytes,taxa_included_exclusions" } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) @@ -479,16 +509,16 @@ if(all.taxonomy){ #'Helper function to set query components. #' @param species Single species or vector of species. #' @keywords internal -.species_check<-function(species){ +.species_check <- function(species){ if(is.null(species)){ - query<-"" + query <- "" }else{ - query<-species_select<-paste(" AND", "scrubbed_species_binomial in (", paste(shQuote(species, type = "sh"),collapse = ', '), ") ") + query <- species_select<-paste(" AND", "scrubbed_species_binomial in (", paste(shQuote(species, type = "sh"),collapse = ', '), ") ") } - output<-as.data.frame(cbind(query),stringsAsFactors = F) - colnames(output)<-c("query") + output <- as.data.frame(cbind(query), stringsAsFactors = FALSE) + colnames(output) <- c("query") return(output) @@ -501,16 +531,16 @@ if(all.taxonomy){ #'Helper function to set query components. #' @param genus Single genus or vector of genera. #' @keywords internal -.genus_check<-function(genus){ +.genus_check <- function(genus){ if(is.null(genus)){ - query<-"" + query <- "" }else{ - query<-species_select<-paste(" AND", "scrubbed_genus in (", paste(shQuote(genus, type = "sh"),collapse = ', '), ") ") + query <- species_select<-paste(" AND", "scrubbed_genus in (", paste(shQuote(genus, type = "sh"),collapse = ', '), ") ") } - output<-as.data.frame(cbind(query),stringsAsFactors = F) - colnames(output)<-c("query") + output <- as.data.frame(cbind(query), stringsAsFactors = FALSE) + colnames(output) <- c("query") return(output) @@ -525,19 +555,23 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.cultivated_check_stem<-function(cultivated){ +.cultivated_check_stem <- function(cultivated){ if(!cultivated){ - query<-"AND (analytical_stem.is_cultivated_observation = 0 OR analytical_stem.is_cultivated_observation IS NULL) AND analytical_stem.is_location_cultivated IS NULL" - select<-"" + + query <- "AND (analytical_stem.is_cultivated_observation = 0 OR analytical_stem.is_cultivated_observation IS NULL) AND analytical_stem.is_location_cultivated IS NULL" + select <- "" + }else{ - query<-"" - select<-",analytical_stem.is_cultivated_observation,view_full_occurrence_individual.is_cultivated_in_region,analytical_stem.is_location_cultivated" + + query <- "" + select <- ",analytical_stem.is_cultivated_observation,view_full_occurrence_individual.is_cultivated_in_region,analytical_stem.is_location_cultivated" + } - output<-as.data.frame(cbind(query,select),stringsAsFactors = F) - colnames(output)<-c("query","select") + output <- as.data.frame(cbind(query,select), stringsAsFactors = FALSE) + colnames(output) <- c("query", "select") return(output) @@ -549,28 +583,28 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.newworld_check_stem<-function(new.world){ +.newworld_check_stem <- function(new.world){ if(is.null(new.world)){ - query<-"" - select<-"" - output<-as.data.frame(cbind(query,select),stringsAsFactors = F) - colnames(output)<-c("query","select") + query <- "" + select <- "" + output <- as.data.frame(cbind(query,select),stringsAsFactors = FALSE) + colnames(output) <- c("query","select") return(output) } if(!new.world){ - query<-"AND analytical_stem.is_new_world = 0 " - select<-",analytical_stem.is_new_world"} + query <- "AND analytical_stem.is_new_world = 0 " + select <- ",analytical_stem.is_new_world"} if(new.world){ - query<-"AND analytical_stem.is_new_world = 1 " - select<-",analytical_stem.is_new_world"} + query <- "AND analytical_stem.is_new_world = 1 " + select <- ",analytical_stem.is_new_world"} - output<-as.data.frame(cbind(query,select),stringsAsFactors = F) - colnames(output)<-c("query","select") + output <- as.data.frame(cbind(query,select), stringsAsFactors = FALSE) + colnames(output) <- c("query","select") return(output) @@ -586,15 +620,20 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.taxonomy_check_stem<-function(all.taxonomy){ +.taxonomy_check_stem <- function(all.taxonomy){ if(!all.taxonomy){ + select<-"" + }else{ + select<-",analytical_stem.verbatim_family,analytical_stem.verbatim_scientific_name,analytical_stem.family_matched,analytical_stem.name_matched,analytical_stem.name_matched_author,analytical_stem.higher_plant_group,analytical_stem.scrubbed_taxonomic_status,analytical_stem.scrubbed_family,analytical_stem.scrubbed_author" + } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) } @@ -605,14 +644,14 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.native_check_stem<-function(native.status){ +.native_check_stem <- function(native.status){ if(!native.status){ - select<-"" + select <- "" }else{ - select<-",analytical_stem.native_status,analytical_stem.native_status_reason,analytical_stem.native_status_sources,analytical_stem.is_introduced,analytical_stem.native_status_country,analytical_stem.native_status_state_province,analytical_stem.native_status_county_parish" + select <- ",analytical_stem.native_status,analytical_stem.native_status_reason,analytical_stem.native_status_sources,analytical_stem.is_introduced,analytical_stem.native_status_country,analytical_stem.native_status_state_province,analytical_stem.native_status_county_parish" } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) } @@ -625,16 +664,16 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.natives_check_stem<-function(natives.only){ +.natives_check_stem <- function(natives.only){ if(!natives.only){ - query<-"" + query <- "" }else{ - query<-"AND (view_full_occurrence_individual.is_introduced=0 OR view_full_occurrence_individual.is_introduced IS NULL)" + query <- "AND (view_full_occurrence_individual.is_introduced=0 OR view_full_occurrence_individual.is_introduced IS NULL)" } - output<-as.data.frame(cbind(query),stringsAsFactors = F) - colnames(output)<-c("query") + output <- as.data.frame(cbind(query),stringsAsFactors = FALSE) + colnames(output) <- c("query") return(output) } @@ -645,15 +684,15 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.political_check_stem<-function(political.boundaries){ +.political_check_stem <- function(political.boundaries){ if(!political.boundaries){ - select<-"" + select <- "" }else{ - select<-",analytical_stem.country,analytical_stem.state_province,analytical_stem.county,analytical_stem.locality" + select <- ",analytical_stem.country,analytical_stem.state_province,analytical_stem.county,analytical_stem.locality" } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) } @@ -665,16 +704,16 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.collection_check_stem<-function(collection.info){ +.collection_check_stem <- function(collection.info){ if(!collection.info){ - select<-"" + select <- "" }else{ - select<-",view_full_occurrence_individual.catalog_number, view_full_occurrence_individual.recorded_by, view_full_occurrence_individual.record_number, view_full_occurrence_individual.date_collected, view_full_occurrence_individual.identified_by, view_full_occurrence_individual.date_identified, view_full_occurrence_individual.identification_remarks " + select <- ",view_full_occurrence_individual.catalog_number, view_full_occurrence_individual.recorded_by, view_full_occurrence_individual.record_number, view_full_occurrence_individual.date_collected, view_full_occurrence_individual.identified_by, view_full_occurrence_individual.date_identified, view_full_occurrence_individual.identification_remarks " } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) } @@ -685,15 +724,15 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.vfoi_check_stem<-function(native.status,cultivated,natives.only,collection.info){ +.vfoi_check_stem <- function(native.status, cultivated,natives.only, collection.info){ if(native.status | cultivated |natives.only | collection.info){ - join<-" JOIN view_full_occurrence_individual ON (analytical_stem.taxonobservation_id = view_full_occurrence_individual.taxonobservation_id)"}else{ - join<-"" + join <- " JOIN view_full_occurrence_individual ON (analytical_stem.taxonobservation_id = view_full_occurrence_individual.taxonobservation_id)"}else{ + join <- "" } - output<-as.data.frame(cbind(join),stringsAsFactors = F) - colnames(output)<-c("join") + output <- as.data.frame(cbind(join),stringsAsFactors = FALSE) + colnames(output) <- c("join") return(output) } @@ -704,18 +743,18 @@ if(all.taxonomy){ #' #'Helper function to set query components. #' @keywords internal -.md_check_stem<-function(all.metadata){ +.md_check_stem <- function(all.metadata){ if(!all.metadata){ - select<-"" + select <- "" }else{ - select<-",plot_metadata.coord_uncertainty_m,plot_metadata.methodology_reference,plot_metadata.methodology_description,growth_forms_included_all, growth_forms_included_trees, growth_forms_included_shrubs, growth_forms_included_lianas, + select <- ",plot_metadata.coord_uncertainty_m,plot_metadata.methodology_reference,plot_metadata.methodology_description,growth_forms_included_all, growth_forms_included_trees, growth_forms_included_shrubs, growth_forms_included_lianas, growth_forms_included_herbs, growth_forms_included_epiphytes, growth_forms_included_notes, taxa_included_all, taxa_included_seed_plants, taxa_included_ferns_lycophytes, taxa_included_bryophytes,taxa_included_exclusions" } - output<-as.data.frame(cbind(select),stringsAsFactors = F) - colnames(output)<-c("select") + output <- as.data.frame(cbind(select), stringsAsFactors = FALSE) + colnames(output) <- c("select") return(output) } diff --git a/cran-comments.md b/cran-comments.md index 4c009ad..cb5fafb 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -39,3 +39,29 @@ * I'm guessing that the hanging is because the queries are either being executed slowly on our end or downloaded slowly if the internet connection is limited. I've updated our vignette so that the more complicated (slow on the server side) or large (slow to download) queries aren't executed. On my machine it now takes less than 50 seconds to rebuild both. If the rebuild is still too slow on your side I can modify the vignette further. Thanks for bearing with me on this, and apologies for the hassle. +>Please write TRUE and FALSE instead of T and F. (Please don't use 'T' or +'F' as vector names.), e.g.: + man/BIEN_occurrence_family.Rd + man/BIEN_occurrence_genus.Rd + man/BIEN_occurrence_spatialpolygons.Rd + man/BIEN_occurrence_species.Rd + man/BIEN_plot_name.Rd + man/BIEN_plot_spatialpolygons.Rd + man/BIEN_plot_state.Rd + man/BIEN_trait_country.Rd + man/BIEN_trait_family.Rd + man/BIEN_trait_genus.Rd + man/BIEN_trait_traitbyfamily.Rd + man/BIEN_trait_traitbygenus.Rd + man/BIEN_trait_traitbyspecies.Rd + +* I've updated these accordingly. I've also updated the code to us TRUE or FALSE instead of T or F throughout (e.g. internally, in vignettes, etc.) + +>Please ensure that you do not use more than 2 cores in your examples, +vignettes, etc. + +* None of our tests, vignettes, or examples use multiple cores + +> Please fix and resubmit. + + diff --git a/man/BIEN_occurrence_family.Rd b/man/BIEN_occurrence_family.Rd index 48a5bee..bf7c044 100644 --- a/man/BIEN_occurrence_family.Rd +++ b/man/BIEN_occurrence_family.Rd @@ -13,7 +13,7 @@ BIEN_occurrence_family( native.status = FALSE, natives.only = TRUE, political.boundaries = FALSE, - collection.info = F, + collection.info = FALSE, ... ) } diff --git a/man/BIEN_occurrence_genus.Rd b/man/BIEN_occurrence_genus.Rd index 7275e11..e1f1d25 100644 --- a/man/BIEN_occurrence_genus.Rd +++ b/man/BIEN_occurrence_genus.Rd @@ -13,7 +13,7 @@ BIEN_occurrence_genus( natives.only = TRUE, observation.type = FALSE, political.boundaries = FALSE, - collection.info = F, + collection.info = FALSE, ... ) } diff --git a/man/BIEN_occurrence_spatialpolygons.Rd b/man/BIEN_occurrence_spatialpolygons.Rd index b96b727..bf3dfbb 100644 --- a/man/BIEN_occurrence_spatialpolygons.Rd +++ b/man/BIEN_occurrence_spatialpolygons.Rd @@ -13,7 +13,7 @@ BIEN_occurrence_spatialpolygons( natives.only = TRUE, observation.type = FALSE, political.boundaries = FALSE, - collection.info = F, + collection.info = FALSE, ... ) } diff --git a/man/BIEN_occurrence_species.Rd b/man/BIEN_occurrence_species.Rd index 9915416..68f80ea 100644 --- a/man/BIEN_occurrence_species.Rd +++ b/man/BIEN_occurrence_species.Rd @@ -13,8 +13,8 @@ BIEN_occurrence_species( natives.only = TRUE, observation.type = FALSE, political.boundaries = FALSE, - collection.info = F, - only.geovalid = T, + collection.info = FALSE, + only.geovalid = TRUE, ... ) } @@ -55,7 +55,7 @@ US FIA coordinates have been fuzzed and swapped, for more details see: https://w BIEN_occurrence_species("Abies amabilis") species_vector<-c("Abies amabilis", "Acer nigrum") BIEN_occurrence_species(species_vector) -BIEN_occurrence_species(species_vector,all.taxonomy=TRUE)} +BIEN_occurrence_species(species_vector,all.taxonomy = TRUE)} } \seealso{ Other occurrence functions: diff --git a/man/BIEN_phylogeny_label_nodes.Rd b/man/BIEN_phylogeny_label_nodes.Rd index 7c29211..3800e4f 100644 --- a/man/BIEN_phylogeny_label_nodes.Rd +++ b/man/BIEN_phylogeny_label_nodes.Rd @@ -37,22 +37,22 @@ Information on the construction of the BIEN phylogenies is available online at h phylogeny<-BIEN_phylogeny_conservative() phylogeny<-drop.tip(phy = phylogeny,tip = 101:length(phylogeny$tip.label)) -plot.phylo(x = phylogeny,show.tip.label = F) +plot.phylo(x = phylogeny,show.tip.label = FALSE) -fam_nodes<-BIEN_phylogeny_label_nodes(phylogeny = phylogeny,family = T) -plot.phylo(x = fam_nodes,show.tip.label = F,show.node.label = T) +fam_nodes<-BIEN_phylogeny_label_nodes(phylogeny = phylogeny,family = TRUE) +plot.phylo(x = fam_nodes,show.tip.label = FALSE, show.node.label = TRUE) -gen_nodes<-BIEN_phylogeny_label_nodes(phylogeny = phylogeny,family = F,genus = T) -plot.phylo(x = gen_nodes,show.tip.label = F,show.node.label = T) +gen_nodes<-BIEN_phylogeny_label_nodes(phylogeny = phylogeny, family = FALSE, genus = TRUE) +plot.phylo(x = gen_nodes, show.tip.label = FALSE, show.node.label = TRUE) -other_taxa<-as.data.frame(matrix(nrow = 10,ncol = 2)) +other_taxa <- as.data.frame(matrix(nrow = 10,ncol = 2)) colnames(other_taxa)<-c("taxon","species") other_taxa$taxon[1:5]<-"A" #Randomly assign a few species to taxon A other_taxa$taxon[6:10]<-"B" #Randomly assign a few species to taxon B tax_nodes <- BIEN_phylogeny_label_nodes(phylogeny = phylogeny, - family = F,genus = F,other_taxa = other_taxa) -plot.phylo(x = tax_nodes,show.tip.label = F,show.node.label = T)} + family = FALSE, genus = FALSE, other_taxa = other_taxa) +plot.phylo(x = tax_nodes,show.tip.label = FALSE,show.node.label = TRUE)} } \seealso{ Other phylogeny functions: diff --git a/man/BIEN_plot_name.Rd b/man/BIEN_plot_name.Rd index 4198796..41924bc 100644 --- a/man/BIEN_plot_name.Rd +++ b/man/BIEN_plot_name.Rd @@ -12,7 +12,7 @@ BIEN_plot_name( native.status = FALSE, natives.only = TRUE, political.boundaries = FALSE, - collection.info = F, + collection.info = FALSE, all.metadata = FALSE, ... ) diff --git a/man/BIEN_plot_spatialpolygons.Rd b/man/BIEN_plot_spatialpolygons.Rd index 23729e6..419a790 100644 --- a/man/BIEN_plot_spatialpolygons.Rd +++ b/man/BIEN_plot_spatialpolygons.Rd @@ -12,7 +12,7 @@ BIEN_plot_spatialpolygons( native.status = FALSE, natives.only = TRUE, political.boundaries = TRUE, - collection.info = F, + collection.info = FALSE, all.metadata = FALSE, ... ) diff --git a/man/BIEN_plot_state.Rd b/man/BIEN_plot_state.Rd index ba0d2fc..b711449 100644 --- a/man/BIEN_plot_state.Rd +++ b/man/BIEN_plot_state.Rd @@ -15,7 +15,7 @@ BIEN_plot_state( native.status = FALSE, natives.only = TRUE, political.boundaries = TRUE, - collection.info = F, + collection.info = FALSE, all.metadata = FALSE, ... ) diff --git a/man/BIEN_ranges_genus.Rd b/man/BIEN_ranges_genus.Rd index 4f8cb7c..9045ba4 100644 --- a/man/BIEN_ranges_genus.Rd +++ b/man/BIEN_ranges_genus.Rd @@ -54,7 +54,7 @@ Abies_poly<-readOGR(dsn = temp_dir,layer = "Abies_lasiocarpa") #Plotting files plot(Abies_poly)#plots the range, but doesn't mean much without any reference map('world', fill = TRUE, col = "grey")#plots a world map (WGS84 projection), in grey -plot(Abies_poly,col="forest green",add=TRUE) #adds the range of Abies lasiocarpa to the map +plot(Abies_poly,col="forest green",add = TRUE) #adds the range of Abies lasiocarpa to the map #Getting data from the files (currently only species names) Abies_poly$Species#gives the species name associated with "Abies_poly"} diff --git a/man/BIEN_ranges_load_species.Rd b/man/BIEN_ranges_load_species.Rd index 5220ee4..aba0e59 100644 --- a/man/BIEN_ranges_load_species.Rd +++ b/man/BIEN_ranges_load_species.Rd @@ -27,8 +27,8 @@ xanthium_strumarium<-BIEN_ranges_load_species(species = "Xanthium strumarium") #Plotting files plot(abies_maps)#plots the spatialpolygons, but doesn't mean much without any reference map('world', fill = TRUE, col = "grey")#plots a world map (WGS84 projection), in grey -plot(xanthium_strumarium,col="forest green",add=TRUE) #adds the range of X. strumarium -plot(abies_maps[1,], add = T, col ="light green")} +plot(xanthium_strumarium,col="forest green",add = TRUE) #adds the range of X. strumarium +plot(abies_maps[1,], add = TRUE, col ="light green")} } \seealso{ Other range functions: diff --git a/man/BIEN_ranges_species.Rd b/man/BIEN_ranges_species.Rd index dbd5d98..69d11a7 100644 --- a/man/BIEN_ranges_species.Rd +++ b/man/BIEN_ranges_species.Rd @@ -54,7 +54,7 @@ Abies_poly<-readOGR(dsn = temp_dir,layer = "Abies_lasiocarpa") #Plotting files plot(Abies_poly)#plots the range, but doesn't mean much without any reference map('world', fill = TRUE, col = "grey")#plots a world map (WGS84 projection), in grey -plot(Abies_poly,col="forest green",add=TRUE) #adds the range of Abies lasiocarpa to the map +plot(Abies_poly,col="forest green",add = TRUE) #adds the range of Abies lasiocarpa to the map #Getting data from the files (currently only species names) Abies_poly$Species#gives the species name associated with "Abies_poly"} diff --git a/man/BIEN_ranges_species_bulk.Rd b/man/BIEN_ranges_species_bulk.Rd index d47b844..dfa6111 100644 --- a/man/BIEN_ranges_species_bulk.Rd +++ b/man/BIEN_ranges_species_bulk.Rd @@ -8,7 +8,8 @@ BIEN_ranges_species_bulk( species = NULL, directory = NULL, batch_size = 1000, - return_directory = TRUE + return_directory = TRUE, + use_parallel = FALSE ) } \arguments{ @@ -19,6 +20,8 @@ BIEN_ranges_species_bulk( \item{batch_size}{The number of ranges to download at once.} \item{return_directory}{Should the directory be returned? Default is TRUE} + +\item{use_parallel}{Logical. Should batches be downloaded in parallel? If set to TRUE, AND if parallel and foreach are available, parallel processing of downloads will use n-1 clusters.} } \value{ Optionally, the directory to which the files were saved. diff --git a/man/BIEN_stem_family.Rd b/man/BIEN_stem_family.Rd index 4de9057..1b0a9de 100644 --- a/man/BIEN_stem_family.Rd +++ b/man/BIEN_stem_family.Rd @@ -54,7 +54,7 @@ Setting either "cultivated" or "native.status" to TRUE will significantly slow t BIEN_stem_family(family = "Marantaceae") family_vector<-c("Marantaceae", "Buxaceae") BIEN_stem_family(family = family_vector) -BIEN_stem_family(family = family_vector, all.taxonomy=TRUE, native.status=T)} +BIEN_stem_family(family = family_vector, all.taxonomy = TRUE, native.status = TRUE)} } \seealso{ Other stem functions: diff --git a/man/BIEN_stem_genus.Rd b/man/BIEN_stem_genus.Rd index 602a223..82150f3 100644 --- a/man/BIEN_stem_genus.Rd +++ b/man/BIEN_stem_genus.Rd @@ -54,7 +54,7 @@ Setting either "cultivated" or "native.status" to TRUE will significantly slow t BIEN_stem_genus(genus = "Tovomita") genus_vector<-c("Tovomita", "Myrcia") BIEN_stem_genus(genus = genus_vector) -BIEN_stem_genus(genus = genus_vector, all.taxonomy=TRUE)} +BIEN_stem_genus(genus = genus_vector, all.taxonomy = TRUE)} } \seealso{ Other stem functions: diff --git a/man/BIEN_stem_species.Rd b/man/BIEN_stem_species.Rd index ef925da..1ae7f26 100644 --- a/man/BIEN_stem_species.Rd +++ b/man/BIEN_stem_species.Rd @@ -54,7 +54,7 @@ Setting either "cultivated" or "native.status" to TRUE will significantly slow t BIEN_stem_species("Abies amabilis") species_vector<-c("Abies amabilis", "Acer nigrum") BIEN_stem_species(species_vector) -BIEN_stem_species(species_vector,all.taxonomy=TRUE)} +BIEN_stem_species(species_vector,all.taxonomy = TRUE)} } \seealso{ Other stem functions: diff --git a/man/BIEN_trait_country.Rd b/man/BIEN_trait_country.Rd index 8eb9b3e..8003d69 100644 --- a/man/BIEN_trait_country.Rd +++ b/man/BIEN_trait_country.Rd @@ -9,7 +9,7 @@ BIEN_trait_country( trait.name = NULL, all.taxonomy = FALSE, political.boundaries = TRUE, - source.citation = F, + source.citation = FALSE, ... ) } diff --git a/man/BIEN_trait_family.Rd b/man/BIEN_trait_family.Rd index b8f9fda..ae40e71 100644 --- a/man/BIEN_trait_family.Rd +++ b/man/BIEN_trait_family.Rd @@ -8,7 +8,7 @@ BIEN_trait_family( family, all.taxonomy = FALSE, political.boundaries = FALSE, - source.citation = F, + source.citation = FALSE, ... ) } diff --git a/man/BIEN_trait_genus.Rd b/man/BIEN_trait_genus.Rd index 2182d63..00f3d5a 100644 --- a/man/BIEN_trait_genus.Rd +++ b/man/BIEN_trait_genus.Rd @@ -8,7 +8,7 @@ BIEN_trait_genus( genus, all.taxonomy = FALSE, political.boundaries = FALSE, - source.citation = F, + source.citation = FALSE, ... ) } @@ -32,7 +32,7 @@ BIEN_trait_genus extracts entries that contain the specified genera. \examples{ \dontrun{ BIEN_trait_genus("Acer") -genus_vector<-c("Acer","Abies") +genus_vector <- c("Acer","Abies") BIEN_trait_genus(genus_vector)} } \concept{trait funcitons} diff --git a/man/BIEN_trait_traitbyfamily.Rd b/man/BIEN_trait_traitbyfamily.Rd index a4248c0..529657c 100644 --- a/man/BIEN_trait_traitbyfamily.Rd +++ b/man/BIEN_trait_traitbyfamily.Rd @@ -9,7 +9,7 @@ BIEN_trait_traitbyfamily( trait, all.taxonomy = FALSE, political.boundaries = FALSE, - source.citation = F, + source.citation = FALSE, ... ) } @@ -38,9 +38,9 @@ Trait spelling needs to be exact and case-sensitive, see \code{\link{BIEN_trait_ \examples{ \dontrun{ BIEN_trait_traitbyfamily(trait = "whole plant height", family = "Poaceae") -trait_vector<-c("whole plant height", "leaf fresh mass") -family_vector<-c("Orchidaceae","Poaceae") -BIEN_trait_traitbyfamily(trait=trait_vector,family=family_vector)} +trait_vector <- c("whole plant height", "leaf fresh mass") +family_vector < -c("Orchidaceae","Poaceae") +BIEN_trait_traitbyfamily(trait = trait_vector, family = family_vector)} } \seealso{ Other trait functions: diff --git a/man/BIEN_trait_traitbygenus.Rd b/man/BIEN_trait_traitbygenus.Rd index 8c193bd..8c6677e 100644 --- a/man/BIEN_trait_traitbygenus.Rd +++ b/man/BIEN_trait_traitbygenus.Rd @@ -9,7 +9,7 @@ BIEN_trait_traitbygenus( trait, all.taxonomy = FALSE, political.boundaries = FALSE, - source.citation = F, + source.citation = FALSE, ... ) } diff --git a/man/BIEN_trait_traitbyspecies.Rd b/man/BIEN_trait_traitbyspecies.Rd index 765bfb8..80b9f8a 100644 --- a/man/BIEN_trait_traitbyspecies.Rd +++ b/man/BIEN_trait_traitbyspecies.Rd @@ -9,7 +9,7 @@ BIEN_trait_traitbyspecies( trait, all.taxonomy = FALSE, political.boundaries = FALSE, - source.citation = F, + source.citation = FALSE, ... ) } diff --git a/old_versions/BIEN_1.2.5.tar.gz b/old_versions/BIEN_1.2.5.tar.gz index 664c804..725afaa 100644 Binary files a/old_versions/BIEN_1.2.5.tar.gz and b/old_versions/BIEN_1.2.5.tar.gz differ diff --git a/vignettes/BIEN_tutorial.Rmd b/vignettes/BIEN_tutorial.Rmd index 63d40f7..e1b2330 100644 --- a/vignettes/BIEN_tutorial.Rmd +++ b/vignettes/BIEN_tutorial.Rmd @@ -118,11 +118,11 @@ If we want more information on these occurrences, we just need to change the arg ```{r xs-occurrences-pt-2, eval = FALSE} Xanthium_strumarium_full <- BIEN_occurrence_species(species = "Xanthium strumarium", - cultivated = T, - all.taxonomy = T, - native.status = T, - observation.type = T, - political.boundaries = T) + cultivated = TRUE, + all.taxonomy = TRUE, + native.status = TRUE, + observation.type = TRUE, + political.boundaries = TRUE) ``` @@ -134,7 +134,7 @@ If we want to take a quick look at where those occurrences are we could use: ```{r map-xs, eval = FALSE} # Make a quick map to plot our points on - map('world', fill = T, col= "grey", bg = "light blue") + map('world', fill = TRUE, col= "grey", bg = "light blue") # Plot the points from the full query in red @@ -172,9 +172,9 @@ Bahamas <- BIEN_occurrence_country(country = "Bahamas") #Now, let's take a look at where those occurrences are: - map(regions = "Bahamas" ,fill = T , col= "grey", bg = "light blue") + map(regions = "Bahamas" ,fill = TRUE , col= "grey", bg = "light blue") - points(cbind(Bahamas$longitude,Bahamas$latitude),col = "blue",pch = 20,cex = 1) + points(cbind(Bahamas$longitude,Bahamas$latitude), col = "blue", pch = 20, cex = 1) #Looks like some islands are considerably better sampled than others. @@ -221,12 +221,12 @@ The range map is now in our global environment as a SpatialPolygonsDataFrame. L #First, let's add a base map so that our range has some context: - map('world',fill = T , col= "grey", bg = "light blue", + map('world', fill = TRUE , col= "grey", bg = "light blue", xlim = c(-180, -20), ylim = c(-60, 80)) #Now, we can add the range map: - plot(Xanthium_strumarium_range, col = "green", add = T) + plot(Xanthium_strumarium_range, col = "green", add = TRUE) @@ -236,11 +236,11 @@ Now, let's add those occurrence points from earlier to this map: ```{r xs-range-and-points} -map('world', fill = T , col = "grey", bg = "light blue", +map('world', fill = TRUE , col = "grey", bg = "light blue", xlim = c(-180, -20), ylim = c(-60, 80)) -plot(Xanthium_strumarium_range, col = "green", add = T) +plot(Xanthium_strumarium_range, col = "green", add = TRUE) points(cbind(Xanthium_strumarium$longitude,Xanthium_strumarium$latitude), col = "blue", pch = 20, cex = 1) @@ -290,11 +290,11 @@ We can see that this is a 0.1 hectare transect where stems >= 2.5 cm diameter at ```{r, eval = FALSE} LUQUILLO_full <- BIEN_plot_name(plot.name = "LUQUILLO", - cultivated = T, - all.taxonomy = T, - native.status = T, - political.boundaries = T, - all.metadata = T) + cultivated = TRUE, + all.taxonomy = TRUE, + native.status = TRUE, + political.boundaries = TRUE, + all.metadata = TRUE) ```