restate {markovmix} | R Documentation |
Reorganize states in MarkovMix object
Description
restate
reorganizes states in MarkovMix
object with a function.
Usage
restate(.object, .fun, .check = TRUE, ...)
Arguments
.object |
|
.fun |
Function to process each column in state transition patterns as factors,
such as those in |
.check |
Logical (1L) indicating whether to check |
... |
Additional arguments passed on to |
Value
A MarkovMix
object with modified states and count matrix.
Note
Change log:
0.1.0 Xiurui Zhu - Initiate the function.
Author(s)
Xiurui Zhu
See Also
Other MarkovMix utilities:
Extract.MarkovMix
,
get_counts()
,
get_order()
,
get_prior()
,
get_prob()
,
get_states_mat()
,
get_states()
Examples
# Load example MarkovMix object
data("markov_mix_ex")
# Reverse states (using function)
markov_mix_new1 <- restate(
.object = markov_mix_ex,
.fun = forcats::fct_rev
)
print(markov_mix_new1)
# Reorder states by hand (using function name with additional arguments)
markov_mix_new2 <- restate(
.object = markov_mix_ex,
.fun = "levels<-",
value = c("B", "D", "C", "A")
)
print(markov_mix_new2)
# Merge state D into C (using purrr-style lambda function)
markov_mix_new3 <- restate(
.object = markov_mix_ex,
.fun = ~ forcats::fct_recode(.x, "C" = "D")
)
print(markov_mix_new3)
[Package markovmix version 0.1.3 Index]