Title: | Miscellaneous Functions by Paul Hoffman |
---|---|
Description: | More about what it does (maybe more than one line) Use four spaces when indenting paragraphs within the Description. |
Authors: | Paul Hoffman [aut, cre] |
Maintainer: | Paul Hoffman <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.0.9001 |
Built: | 2024-11-11 02:58:07 UTC |
Source: | https://github.com/mojaveazure/mamisc |
More about what it does (maybe more than one line) Use four spaces when indenting paragraphs within the Description.
Maintainer: Paul Hoffman [email protected] (ORCID)
Useful links:
Create Abbreviations
abbrv(x, digits = TRUE)
abbrv(x, digits = TRUE)
x |
A character vector |
digits |
Include digits in the abbreviation |
Abbreviated versions of x
abbrv(c('HelloWorld', 'LetsGo3', 'tomato')) abbrv(c('HelloWorld', 'LetsGo3', 'tomato'), digits = FALSE) abbrv('Wow3', digits = FALSE)
abbrv(c('HelloWorld', 'LetsGo3', 'tomato')) abbrv(c('HelloWorld', 'LetsGo3', 'tomato'), digits = FALSE) abbrv('Wow3', digits = FALSE)
Blend two or more colors together
blend_colors(..., as.rgb = FALSE)
blend_colors(..., as.rgb = FALSE)
... |
Two or more colors to blend together; these can be in a vector or standalone |
as.rgb |
Return in RGB form, otherwise return in hexadecimal form |
The blended color in RGB form (1 x 3 matrix) or hexadecimal form
Other color_theory:
col2hex()
,
contrast-theory
,
text_color()
blend_colors('red', 'green') if (requireNamespace('scales', quietly = TRUE)) { scales::show_col(c('red', blend_colors('red', 'green'), 'green'), ncol = 3) }
blend_colors('red', 'green') if (requireNamespace('scales', quietly = TRUE)) { scales::show_col(c('red', blend_colors('red', 'green'), 'green'), ncol = 3) }
Convert R colors to hexadecimal
col2hex(...)
col2hex(...)
... |
R colors |
The hexadecimal representations of input colors
Other color_theory:
blend_colors()
,
contrast-theory
,
text_color()
col2hex('black', 'red', 'grey')
col2hex('black', 'red', 'grey')
Get the intensity and/or luminance of a color
intensity(color) luminance(color)
intensity(color) luminance(color)
color |
A vector of colors |
A vector of intensities/luminances for each color
Other color_theory:
blend_colors()
,
col2hex()
,
text_color()
intensity(color = c('black', 'white', '#E76BF3')) luminance(color = c('black', 'white', '#E76BF3'))
intensity(color = c('black', 'white', '#E76BF3')) luminance(color = c('black', 'white', '#E76BF3'))
Interleave vectors together
interleave(...)
interleave(...)
... |
Vectors to be interleaved |
A vector with the values from each vector in ... interleaved
Is an Object a Data Frame
is_data_frame(x) is_bare_data_frame(x)
is_data_frame(x) is_bare_data_frame(x)
x |
An object |
TRUE
if x
is a data frame, otherwise FALSE
Is a List Named
is_named_list(x, pass.zero = FALSE)
is_named_list(x, pass.zero = FALSE)
x |
A list |
pass.zero |
Return |
...
NULL
Vectorized Testing of NULL
is_nullv(x)
is_nullv(x)
x |
A list-like object |
...
Hide Shiny Tabs with ShinyJS
js_tab_hide(id, values, fxn = "hide")
js_tab_hide(id, values, fxn = "hide")
id |
ID of a |
values |
One or more values of a |
fxn |
Name of JavaScript call function |
A string with a JavaScript function to hide a set of tabs
This function is designed to run custom JavaScript code using
shinyjs::extendShinyJS()
; use of
custom JavaScript code requires the V8 package.
V8 requires a local install of either the
V8 JavaScript Engine or
Node.js
shinyjs::extendShinyJS()
shiny::tabPanel()
Other shiny:
js_tab_key()
Other shinyjs:
js_tab_key()
Get JavaScript IDs for Shiny Tabs
js_tab_key(id, values)
js_tab_key(id, values)
id |
ID of a |
values |
One or more values of a |
A string with the JavaScript ID for a given set of tabs
shiny::tabsetPanel()
shiny::tabPanel()
Other shiny:
js_tab_hide()
Other shinyjs:
js_tab_hide()
Check to see if a given resource is online and accessible over the internet
online(uri, strict = FALSE, timeout = getOption(x = "timeout"))
online(uri, strict = FALSE, timeout = getOption(x = "timeout"))
uri |
The URI of a given resource |
strict |
Ensures the HTTP status code is |
timeout |
Timeout in seconds; defaults to the option
“ |
TRUE
if uri
is accessible, otherwise FALSE
This function requires the \href{https://cran.r-project.org/package=httr}{\pkg{httr}} package to be installed
Keyed Ordering Permutation
order2( ..., key = identity, na.last = TRUE, decreasing = FALSE, method = c("auto", "shell", "radix") )
order2( ..., key = identity, na.last = TRUE, decreasing = FALSE, method = c("auto", "shell", "radix") )
... |
a sequence of numeric, complex, character or logical vectors, all of the same length, or a classed R object. |
key |
A function that takes a single argument, defaults to
|
na.last |
for controlling the treatment of |
decreasing |
logical. Should the sort order be increasing or
decreasing? For the |
method |
the method to be used: partial matches are allowed. The
default ( |
An integer vector with the ordered indices of the input data
Create a List with a Serial Comma
oxford( ..., cnj = c("or", "and"), quote = c("single", "double", "none"), fancy = getOption(x = "useFancyQuotes", default = TRUE) )
oxford( ..., cnj = c("or", "and"), quote = c("single", "double", "none"), fancy = getOption(x = "useFancyQuotes", default = TRUE) )
... |
A character vector to join |
cnj |
Conjunction to use for final entry |
quote |
Quote the entries of
|
fancy |
Use fancy quotes; defaults to the value of the
“ |
...
arranged into an English list with a serial comma
when needed
oxford('cell') oxford('cell', 'ident') oxford('cell', 'ident', 'gene')
oxford('cell') oxford('cell', 'ident') oxford('cell', 'ident', 'gene')
Generate a powerset
powerset(x)
powerset(x)
x |
A list or vector of values to generate all possible combinations of |
A list with all possible combinations of x
powerset(x = 1:3) powerset(x = letters[1:3])
powerset(x = 1:3) powerset(x = letters[1:3])
Generate an Rdocumentation itemized list
rd_ilist(x)
rd_ilist(x)
x |
A vector of values for the list |
An Rdocumentation itemized list suitable for injecting into
documentation files with \Sexpr
Other roxygen:
rd_required_pkgs()
#' \Sexpr[results=rd]{odds::rd_ilist()}
#' \Sexpr[results=rd]{odds::rd_ilist()}
Rdocumentation Note of Required Packages
rd_required_pkgs(x, multiple = FALSE)
rd_required_pkgs(x, multiple = FALSE)
x |
A vector of package names |
multiple |
... |
...
Other roxygen:
rd_ilist()
#' \Sexpr[results=rd]{odds::rd_required_pkgs()}
#' \Sexpr[results=rd]{odds::rd_required_pkgs()}
Sort With A Key
sorted(x, key = identity, decreasing = FALSE, ...) ## Default S3 method: sorted(x, key = identity, decreasing = FALSE, na.last = NA, ...)
sorted(x, key = identity, decreasing = FALSE, ...) ## Default S3 method: sorted(x, key = identity, decreasing = FALSE, na.last = NA, ...)
x |
for |
key |
A function that takes a single argument, defaults to
|
decreasing |
logical. Should the sort be increasing or decreasing? Not available for partial sorting. |
... |
arguments to be passed to or from methods or (for the
default methods and objects without a class) to |
na.last |
for controlling the treatment of |
Determine text color based on background color
text_color( background, threshold = 186, w3c = FALSE, dark = "black", light = "white" )
text_color( background, threshold = 186, w3c = FALSE, dark = "black", light = "white" )
background |
A vector of background colors; supports R color names and hexadecimal codes |
threshold |
Intensity threshold for light/dark cutoff; intensities
greater than |
w3c |
Use W3C formula for calculating
background text color; ignores |
dark |
Color for dark text |
light |
Color for light text |
A named vector of either dark
or light
, depending on
background
; names of vector are background
Other color_theory:
blend_colors()
,
col2hex()
,
contrast-theory
text_color(background = c('black', 'white', '#E76BF3'))
text_color(background = c('black', 'white', '#E76BF3'))