View source: R/periods_to_long.R
periods_to_long | R Documentation |
Transform a data frame from period format to long format
periods_to_long(
data,
start,
stop,
time_step = 1,
time_name = "time",
keep = FALSE
)
data |
A data frame, or a data frame extension (e.g. a tibble). |
start |
< |
stop |
< |
time_step |
(numeric) Desired value for the time variable. |
time_name |
(character) Name of the time variable. |
keep |
(logical) Should start and stop variable be kept in the results? |
A tibble.
long_to_periods()
d <- dplyr::tibble(
patient = c(1, 2, 3, 3),
begin = c(0, 2, 0, 3),
end = c(6, 4, 2, 8),
covar = c("no", "yes", "no", "yes")
)
d
d |> periods_to_long(start = begin, stop = end)
d |> periods_to_long(start = begin, stop = end, time_step = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.