Utilities: Utilities Useful tools for programming.

Description Usage Arguments Details Value Examples

Description

Utilities Useful tools for programming.

Usage

1
2
3
4
5
6
7
now()

bquote.arg(x)

check.types(...)

quantize(x, init, step, bias = c("round", "floor", "ceiling"))

Arguments

x

a vector of values

...

named arguments, where the name of the argument is a variable class, and the argument itself is the value to be checked for its type. function cannot be provided as argument name, so the shorthand fun must be used.

init

an initial value

step

steps over which to be quantized

bias

when quantizing, should the value be rounded up or down?

Details

now() returns the current numeric Linux timestamp.

bquote.arg() is to be used inside functions. It returns the content of the argument as a call, but evaluates parts of the argument that were wrapped inside .(), akin to bquote().

check.types() checks the class of its arguments, and errors if an argument does not match the class that was provided as argument name.

quantize() quantizes a vector.

Value

quantize() returns a quantized numeric vector.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
now()
testfunction<-function(x){ bquote.arg(x) }
testfunction(a + b)
# a + b
testfunction(a + b + .(5+5))
# a + b + 10
check.types(numeric=3,character="a",fun=read.csv)
# TRUE
## Not run: 
check.types(numeric="3")

## End(Not run)
# Error in check.types(numeric = "3") :
# Argument 1 with value 3 should be of type numeric, but is of type character
quantize(1:20,0.5,2,"ceiling")
# 2.5  2.5  4.5  4.5  6.5  6.5  8.5  8.5 10.5 10.5 12.5 12.5 14.5 14.5 16.5 16.5 18.5 18.5 20.5 20.5

Spiritspeak/often documentation built on Feb. 2, 2021, 11:41 a.m.