[Rd] suggestion: default v.names in reshape

Gabor Grothendieck ggrothendieck at gmail.com
Sat Apr 4 16:51:19 CEST 2009


For reshape(dir = "long", varying = list(...), ...)

it would be convenient if the names of the varying
list, if supplied, were used as the default v.names.
Currently they are ignored.

Thus one would be able to write:

# test data frame
d <- structure(list(V.1 = 1:10, V.2 = c(1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L, 2L, 2L), V.3 = 101:110, V.4 = 201:210, V.5 = 301:310, V.6 = 9101:9110,
    V.7 = 9201:9210, V.8 = 9301:9310), row.names = c(NA, -10L
), class = "data.frame", .Names = c("V.1", "V.2", "V.3", "V.4",
"V.5", "V.6", "V.7", "V.8"))

# proposed
reshape(d, dir = "long", varying = list(A = 3:5, B = 6:8))

# as opposed to

# current
reshape(d, dir = "long", varying = list(3:5, 6:8), v.names = c("A", "B"))

which eliminates the need for one argument and makes it more
obvious what the correspondence is between the v.names and
the varying variables.

The old way could still work too so it would be backward
compatible.



More information about the R-devel mailing list