create_quantiles
is a parsimonious function for generating quantiles of a vector (e.g., quartiles for num=4
or quintiles for num=5
). Basically a wrapper for the cut
function; the type of the output is factor
. Fails for vectors with overlapping quantiles (e.g., with >50% of values of x
equal to zero) unless the correct number of labels (i.e., the number of unique quantile breaks) is given in the labels
argument.
to.pct
converts a number (probably a proportion, i.e., typically between 0 and 1) to a percentage; also has an argument (dig
) which can be used to round the output inline.
nx.mlt
returns the least multiple of n
which (weakly) exceeds x
. Convenient for making axes ticks land on pretty numbers.
divide
divides the range (min through max) of x
into n
points (basically a shorthand for seq
).
dol.form
takes a financial input and converts it to a (American-formatted, American-currency) string for printing--appending a dollar sign ("\$"
) and inserting commas after every third digit from the left of the decimal point.
ntostr
converts n
to a character
vector with each element width dig
. This is particularly nice for converting 99:100 to "99" and "100".
write.packages
captures the current package environment (inspired by sessionInfo()
and writes it as a JSON to con
with writeLines
; a list
version of this object is returned. This may be essential for tracking across time which package versions were being used.
stale_package_check
reads a file (with readLines
) and checks which functions are actually used from each loaded package. Currently only checks for library
(i.e., not require
) calls.
embed.mat
inserts a supplied matrix into a (weakly) larger enclosing matrix, typically filled with 0s, at a specified position.
get_age
returns the accurate, fractional age (in years) of each individual, quickly. Accuracy deteriorates when non-leap century years are involved (i.e., any year congruent to 0 mod 100 but not 0 mod 400); designed for use with currently-relevant birthdays and ages.
quick_year
converts a Date
object into its year efficiently; also ignores concerns of leap centuries. quick_mday
returns the day of the month. quick_yday
returns the day of the year. Returns as an integer
.