| complete_visits | R Documentation |
Expand long-format data to all subject and visit combinations
complete_visits(data, id, time, response = NULL, levels = NULL)
data |
(data.frame) data in long format |
id |
(character) name of the subject variable |
time |
(character) name of the visit variable. In the returned data
this variable is a factor with levels |
response |
(character) optional name of the response variable which is
set to |
levels |
(vector) visit levels. Defaults to the levels of the visit variable if it is a factor, and otherwise its sorted unique values. |
Returns a long-format data.frame with exactly one row per subject and visit
(levels), sorted by subject (in order of first appearance) and visit.
Rows that are not present in data are added by copying all columns from
the previous existing row of the subject (last observation carried
forward), or from the next existing row if there is no previous row. The
response of added rows is set to NA.
data.frame with length(levels) rows per subject
d <- data.frame(id = c(1, 1, 2), visit = c(1, 2, 2), y = 1:3, x = 4:6)
complete_visits(d, "id", "visit", "y")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.