remove_duplicated_states | R Documentation |
Remove duplicated consecutive states from data. If for an individual there is two or more consecutive states that are identical, only the first is kept. Only time when the state changes are kept.
remove_duplicated_states(data, keep.last = TRUE)
data |
data.frame containing |
keep.last |
if TRUE, keep the last state for every individual even if it is a duplicated state. |
data
without duplicated consecutive states
Quentin Grimonprez
Other format:
convertToCfd()
,
cut_data()
,
matrixToCfd()
data <- data.frame(
id = rep(1:3, c(10, 3, 8)), time = c(1:10, 1:3, 1:8),
state = c(rep(1:5, each = 2), 1:3, rep(1:3, c(1, 6, 1)))
)
out <- remove_duplicated_states(data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.