This is just a random collection of functions for coding in R with no specific focus.
Notes:
There should be no problems in installing the package with a clang
compiler. However, some functions in the Armadillo
library rely on
OpenMP
for multithreading. As clang
does not support OpenMP
,
all Armadillo
functions will run sequentially. If you want to
enable multithreading via OpenMP
, you might follow the instruction
on this
website.
While all functions were tested, some were tested more rigorously
than others. The scripts for the unit-tests can be found in
~tests/testthat
directory.
predict_ci
: Calculating confidence intervals for predictions based
on GLMs. For polr
and multinom
objects, Monte Carlo simulations
are used; for lm
and glm
objects, endpoints of the confidence
interval of the linear predictor are inverted.lr_modularity
: calculates the LinkRank modularity (Kim et
al. 2010) of a graph partition.adj_sum_partition
: sums within-partition weights of adjacency
matrixadj_sum_partition_sp
: same as adj_sum_partition
but optimized
for sparse
adjacency matricesadj_to_dyadlist
: Transforms an adjacency matrix into a dyad-list
(not to be confused with a edge-list)symmetrize
: symmetrizes a matrix by either copying the
upper-triangle into the lower-triangle or vice versareciprocated
: creates an indicator of whether a tie is
reciprocated from an edge listupdate_affilliation
: Updates a sparse
affiliation matrix
(group-by-group) with data on ego-networks.sp_eigen_adj
: Extracts eigenvalues/vectors from adjacency,
normalized adjacency, Laplacian, and normalized Laplacian matrices
based on a sparse
adjacency matrix.components_adj
: Extracts the components of a graph based on its
sparse
adjacency matrix.is_connected_adj
: Determines whether a graph is connected based on
its sparse
adjacency matrix.mutual_info
: Mutual information based on a cross table of
frequencies. Available meausures are:row_pdist
: Minkowski distancesfrow_euc_dist
: fast (but numerically less stable) calculation
of Euclidean distancesrow_cos_sim
: cosine similarityfrow_cos_sim
: fast (though numerically less stable)
calculation of of cosine similaritysample_logp
: Same function as sample()
but takes a
log-probability vector as argument. The vector might be normalized
or only given up to a proportionality constant.run_mean
: calculates the running average over a numeric vector for
different window sizesreorder_labels
: reorders the labels of an integer
, character
,
or factor
variable according to the frequencies with which the
labels occurquantilize
: categorizes a numeric
vector into a factor
using a
number of quantiles as cut-pointsfind_interval
: finds within which interval a value falls for a
variable created by quantilize
colMedians
: calculates the median of the columns of a numeric
matrixrowMedians
: calculates the median of the rows of a numeric matrixdouble_center
: double-center a matrixgen_agreemat
: creates an agreement matrix by comparing the columns
(or rows) acrros rows (or columns) and counts the number of entries
on which they have the same valueR
Functionslog_sum_exp
: stable calculation of log(sum(exp(x)))
, where x
might be a vector or matrixlog_accu_exp
: stable calculation of log(cumsum(exp(x)))
, where
x
might be a vector or matrixlog_add_exp
: stable calculation of log(exp(x) + exp(y))
, where
x
and y
are real numberssoftmax
: stable calculation of exp(x) / sum(exp(x))
log_softmax
: stable calculation of log(exp(x) / sum(exp(x)))
inv_logit
: inverse-logit function (logistic transform)R
Functions for Printinground_to_char
: rounds a numeric
vector to a character
vector
keeping trailing zerosdf_to_message
: prints data.frame/data.table
as a message
to
the frequencies with which the labels appearupper_first_char
: changes the first character of a string (or
vector of strings) to upper caseKim, Youngdo, Seung-Woo Son, and Hawoong Jeong. 2010. “Finding communities in directed networks,” Physical Review E 81(1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.