Convert long panel data to wide formatSource:
This function takes
panel_data() objects as input as converts
them to wide format for use in SEM and other situations when such a format
When the variables are labeled with the wave number, what should separate the variable name and wave number? By default, it is "_". In other words, a variable named
var_2, and so on in the wide data frame.
datawas created by
long_panel(), it stores information about which variables vary over time and which are constants. Sometimes, though, this information is not accurate ( it is only based on the wide data's variable names) and you may want to force this function to check again based on the actual values of the variables.
If you want to skip the checks for whether variables are varying and specify yourself, as is done with
stats::reshape(), you can supply them as a vector here.
This is a wrapper for
stats::reshape(), which is renowned for being
pretty confusing to use. This function automatically detects which of the
variables vary over time and which don't, not appending wave information
wages <- panel_data(WageData, id = id, wave = t) wide_wages <- widen_panel(wages)