reshape_wide | R Documentation |
Takes the variables in a long-form data frame, widen
, response
, and ID
, and transforms to a wide form data frame. All other variables are deleted in the transformed data frame. A simple wrapper for Base R reshape
with sensible parameter names and sensible defaults, and able to specify a range of variables to transform. Conversion currently limited to converting based on a single grouping variable.
reshape_wide(data, widen, response, ID, prefix=NULL, sep="_", ...)
data |
Data frame that contains the variables to analyze as a wide-form single column. |
widen |
Name of the (single) 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 |
... |
Older parameter values to be converted internally. |
Here is the correspondence between the original reshape
parameter names and the reshape_wide
parameter names.
reshape | reshape_wide |
----------- | ---------------- |
v.names | response |
timevar | widen |
idvar | ID |
----------- | ---------------- |
David W. Gerbing (Portland State University; gerbing@pdx.edu)
reshape
.
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, widen=Group, response=Response, ID=Person)
# with the name of the response prefixed to the column names
reshape_wide(dl, widen=Group, response=Response, ID=Person,
prefix=TRUE, sep=".")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.