[Rd] Incorrect behavior for ordering timepoints in "reshape" (PR#7669)

davclark at nyu.edu davclark at nyu.edu
Mon Feb 7 21:20:15 CET 2005


Full_Name: Dav Clark
Version: 2.0.1
OS: OS X 10.3
Submission from: (NULL) (128.122.87.35)


When the timepoints that reshape uses (in direction="long") are negative or
fractional, the time label is assigned incorrectly.  It is easier to give an
example than to describe the problem abstractly:

Assume you have a data.frame header with values related to peri-stimulus time
like this:

"HRF -5" "HRF -2.5" "HRF 0" "HRF 2.5" ... "HRF 10"

And you give reshape a split argument of a space " ".

Then the labels will be assigned strangely, based on alphabetical ordering.  So
the above list order maps to:

-2.5, -5, 0, 10, ... 2.5

Items under the "HRF -5" column in wide format recieve a -2.5 label, items under
"HRF 2.5" receive a label of 10, and so on.

Somewhere, the time labels are being used before conversion to numbers.  But,
reshape returns an error if it is not possible to convert the timepoints to
numeric!  So obviously, more functionality could be provided, or at least the
documentation should reflect the current shortfall.

For completeness, here is a minimal example demonstrating the bug:

df <- data.frame(id="S1", V1="from -2", V2="from -1")
names(df)[2:3] <- c("vals.-2", "vals.-1")
df
reshape(df, direction="long", varying=2:3)

Thanks!
Dav



More information about the R-devel mailing list