#' Formating p-values
#' Source: http://stackoverflow.com/questions/23018256/printing-p-values-with-0-001
#' @export
format_pval <- function(pvals, sig.limit = .001, digits = 3, html = FALSE) {
roundr <- function(x, digits = 1) {
res <- sprintf(paste0('%.', digits, 'f'), x)
zzz <- paste0('0.', paste(rep('0', digits), collapse = ''))
res[res == paste0('-', zzz)] <- zzz
res
}
sapply(pvals, function(x, sig.limit) {
if (x < sig.limit)
if (html)
return(sprintf('< %s', format(sig.limit))) else
return(sprintf('< %s', format(sig.limit)))
if (x > .1)
return(roundr(x, digits = 2)) else
return(roundr(x, digits = digits))
}, sig.limit = sig.limit)
}
#' Print colour wheel
#'
#' @description
#' Print colour wheel
#'
#' @references
#' https://www.r-bloggers.com/colour-wheels-in-r/
#'
#' @export
#'
#' @examples
#' col_wheel("red")
#' col_wheel("dark")
#'
col_wheel <- function(str, cex=0.75) {
cols <- colors()[grep(str, colors())]
pie(rep(1, length(cols)), labels=cols, col=cols, cex=cex)
cols
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.