isolate: Create isolated within- (and optionally between-) person variables.
Description
Creates variables that represent pure within- and between-person predictors.
Usage
isolate(d = NULL, by = NULL, value = NULL, z = FALSE, which = "within")
Value
A data.frame with additional columns for the within- and
between-person variables. The new columns are labelled _cw for
centered-within and _cb for centered-between.
Arguments
d
A data.frame.
by
A vector of values in d by which the data is clustered.
i.e. a vector of unique participant IDs.
value
Names of columns in d to isolate. Multiple values can be
given by value = c("var1", "var2", "var3")
z
Should the created values be standardized (defaults to FALSE).
which
Which component to return. "within" (default) returns
within-person deviations only; "between" returns between-person means only;
"both" returns both.
# Create within-person deviations of work stressors in BLch9.data(BLch9)
BLch9 <- isolate(BLch9, by = "id", value = "fwkstrs")
head(BLch9) # Now has new column for within-person work stressors.