Replaces a continuous variable x in the data frame, and possibly another continuous variable x_ns derived from it, with new values, for each level of a grouping factor (usually id)

new_x(data, x_values, group_by = "id", x = "age", x_ns = NULL)

Arguments

data

A data frame. Can also be an lgpfit or lgpmodel object, in which case data is extracted from it.

x_values

the values of x to set for each individual

group_by

name of the grouping variable, must be a factor in data (or use group_by=NA to create a dummy grouping factor which has only one value)

x

of the variable along which to extend, must be a numeric in data

x_ns

of a nonstationary variable derived from x, must be a numeric in data

Value

a data frame containing the following columns

  • all factors in the original data

  • x

  • x_ns (unless it is NULL)

See also

Other data frame handling functions: add_dis_age(), add_factor(), add_factor_crossing(), adjusted_c_hat(), split()