View source: R/long_to_periods.R
long_to_periods | R Documentation |
Transform a data frame from long format to period format
long_to_periods(data, id, start, stop = NULL, by = NULL)
data |
A data frame, or a data frame extension (e.g. a tibble). |
id |
< |
start |
< |
stop |
< |
by |
< |
A tibble.
periods_to_long()
d <- dplyr::tibble(
patient = c(1, 2, 3, 3, 4, 4, 4),
begin = c(0, 0, 0, 1, 0, 36, 39),
end = c(50, 6, 1, 16, 36, 39, 45),
covar = c("no", "no", "no", "yes", "no", "yes", "yes")
)
d
d |> long_to_periods(id = patient, start = begin, stop = end)
d |> long_to_periods(id = patient, start = begin, stop = end, by = covar)
# If stop not provided, it is deduced.
# However, it considers that observation ends at the last start time.
d |> long_to_periods(id = patient, start = begin)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.