| reshape_wide {lessR} | R Documentation |
Reshape a Wide-Form Data Frame to Wide-Form
Description
A simple wrapper for Base R reshape with sensible parameter names and sensible defaults, and able to specify a range of variables to transform.
Usage
reshape_wide(data, group, response, ID, prefix=NULL, sep="_")
Arguments
data |
Data frame that contains the variables to analyze wide-form single column. |
group |
Name of the grouping variable in the input long-form column. |
response |
Name of the variable of the response values in the input long-form column. |
ID |
Name of the ID field in the long-form column. |
prefix |
If |
sep |
If |
Details
reshape_wide takes the variables in the long-form group, response, and ID and transforms to wide form. All other variables are deleted in the transformed data frame.
Here is the correspondence between the original reshape parameter names and the reshape_wide parameter names.
| reshape | reshape_wide |
| ----------- | ---------------- |
v.names | response |
timevar | group |
idvar | ID |
| ----------- | ---------------- |
Author(s)
David W. Gerbing (Portland State University; gerbing@pdx.edu)
See Also
Examples
d <- Read("Anova_rb") # already in wide-form
dl <- reshape_long(d, sup1:sup4) # convert to long-form
# convert back to wide form
reshape_wide(dl, group="Group", response="Response", ID="Person")
# with the name of the response prefixed to the column names
reshape_wide(dl, group="Group", response="Response", ID="Person",
prefix=TRUE, sep=".")