repeat_baseline_values {lvmisc} | R Documentation |
Repeat baseline levels
Description
Returns a vector with the length equal to the number of rows in the
data
with the baseline value of the var
repeated for every
time
value of each id
.
Usage
repeat_baseline_values(data, var, id, time, baseline_level, repeat_NA = TRUE)
Arguments
data |
A data frame. |
var |
The bare (unquoted) name of the column with the values to be repeated. |
id |
The bare (unquoted) name of the column that identifies each subject. |
time |
The bare (unquoted) name of the column with the time values. |
baseline_level |
The value of |
repeat_NA |
A logical vector indicating whether or not |
Value
A vector of the same lenght and class of var
.
Examples
df <- data.frame(
id = rep(1:5, each = 4),
time = rep(1:4, 5),
score = rnorm(20, mean = 10, sd = 2)
)
df$baseline_score <- repeat_baseline_values(df, score, id, time, 1)
df
[Package lvmisc version 0.1.2 Index]