repeat_baseline_values: Repeat baseline levels

Description Usage Arguments Value Examples

View source: R/repeat_baseline_values.R

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

1
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 time corresponding the baseline.

repeat_NA

A logical vector indicating whether or not NA values in the var will correspond to NA values in return vector. Defaults to TRUE.

Value

A vector of the same lenght and class of var.

Examples

1
2
3
4
5
6
7
8
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

lvmisc documentation built on April 5, 2021, 5:06 p.m.