Description Usage Arguments Details Value Author(s) See Also Examples
This function reshapes a data frame that contains pair comparison data in 'wide' format into a data frame in 'long' format (see 'Details').
1 |
data |
a data frame in 'wide' format. |
paircomp |
a character vector specifying the columns from |
names |
a character vector of the same length as |
... |
arguments to be passed to |
In the 'wide' format each row reflects a certain subject/judge and a column contains for example the results of a pair comparison or is a subject-specific covariate. In the 'long' format each row represents a single pair comparison.
The reshaped data frame.
Giuseppe Casalicchio
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | data(CEMSwide)
# Define variable names containing the outcome of the comparisons
columns <- colnames(CEMSwide)[grep("V",colnames(CEMSwide))]
# Define names of the objects that are compared (shoud be separated with space)
# "London Paris" means that the first object is "London" and the second "Paris".
comparison <- c("London Paris", "London Milano", "Paris Milano",
"London St.Gallen", "Paris St.Gallen",
"Milano St.Gallen", "London Barcelona",
"Paris Barcelona", "Milano Barcelona",
"St.Gallen Barcelona", "London Stockholm",
"Paris Stockholm", "Milano Stockholm",
"St.Gallen Stockholm", "Barcelona Stockholm")
# Transform to 'long' format where v.names="Y" sets the name of
# our response variable (see ?reshape)
CEMSlong <- wide2long(data=CEMSwide, paircomp=columns, names=comparison, v.names="Y")
head(CEMSlong)
head(CEMSwide)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.