View source: R/mobilityMatrixFunctions.R
getTMatrix | R Documentation |
Returns transition matrix from two columns in dataset. Supports relative, mixed, and absolute transition matrices as well as handling an excluded value.
getTMatrix( dat, col_x, col_y, type, probs = TRUE, num_ranks, exclude_value, bounds, rerank_exclude_value, strict = TRUE )
dat |
a dataframe with an "id" column |
col_x |
a character string denoting the first column from dat to be used in the transition matrix |
col_y |
a character string denoting the second column from dat to be used in the transition matrix |
type |
a character string indicating the type of transition matrix; accepts 'relative', 'mixed', and 'absolute' |
probs |
logical. If TRUE, values in transition matrix are probabilities; if FALSE, values in transition matrix are counts |
num_ranks |
an integer specifying the number of ranks for a relative or mixed transition matrix |
exclude_value |
a single numeric value that is excluded in calculating the transition matrix; see the rerank_exclude_value parameter to specify how the exclude value is handled |
bounds |
a sequence of numeric bounds for defining absolute transition matrix ranks |
rerank_exclude_value |
a character string indicating how the exclude value is handled when present; accepts 'as_new_rank', 'as_existing_rank', and 'exclude' |
strict |
logical. If TRUE, transition matrix is calculated from the given values. If FALSE, transition matrix is calculated by jittering the values to ensure uniqueness of bounds. Only used with relative and mixed types. |
Returns a list with a transition matrix as a Matrix and vectors of the the x and y bounds corresponding to the ranks in the matrix
data(incomeMobility) getTMatrix(dat = incomeMobility, col_x = 't0', col_y = 't9', type = 'relative', num_ranks = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.