This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot_palette <- function(v) { | |
pardefault <- par() | |
call <- format(substitute(v)) | |
n <- length(v) | |
par(mar = c(0,0,0,0)+0.05, bty = "n") | |
plot(NA,NA, type = "n", xaxt = "n", yaxt = "n", xlim = c(0,1), ylim = c(0,1), | |
asp =1/10) | |
rect(xleft = seq(0,1,1/n)[1:n], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' BExIS access over a Webservice | |
#' | |
#' Read table from a web service. Inherits functionality of `read.table()`. | |
#' | |
#' @param datasetid Integer BExIS ID of the requested dataset. | |
#' @param user User name on BExIS. If not provided, function will prompt input. | |
#' @param pswd Password on BExIS. If not provided, function will prompt input. | |
#' @param dec the character used in the file for decimal points. | |
#' @param na.strings a character vector of strings which are to be interpreted as NA values. Blank fields are also considered to be missing values in logical, integer, numeric and complex fields. | |
#' @param fill logical. If TRUE then in case the rows have unequal length, blank fields are implicitly added. See 'Details' of `?read.table`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Get accepted canonical names and taxonomy for a given species name | |
#' | |
#' @param x a character string or vector of species names. | |
#' @param infraspecies logical. If TRUE, the given name is resolved to infraspecies taxon, i.e. subspecies names will not be pooled (not working!) | |
#' @param fuzzy logical. If TRUE, function tries fuzzy matching for species requests. May produce output, if normal matching fails. (not working!) | |
#' @param verbose logical. If FALSE, warnings and messages are suppressed. | |
#' | |
#' @return a data.frame of accepted taxon names and higher taxa. | |
#' @import taxize | |
#' @import data.table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
highlight <- function(x, colrange = c("black", "red2"), steps = NULL, range = "auto"){ | |
if(is.null(steps)) steps = length(unique(x)) | |
if(range[1] == "auto") { | |
min_val = min(x, na.rm = TRUE) | |
max_val = max(x, na.rm = TRUE) | |
} else { | |
min_val = range[1] | |
max_val = range[2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# identify and count the size of individual patches | |
patches <- function(x, state) { | |
pattern <- x$cells | |
pattern <- pattern %in% state | |
map <- rep(NA, times = prod(x$dim)) | |
old <- rep(99, times = prod(x$dim)) | |
while(!identical(old[pattern], map[pattern])) { | |
old <- map |