[Rd] 'sep' argument in reshape()
Martin Maechler
maechler at stat.math.ethz.ch
Wed Apr 1 09:32:41 CEST 2009
>>>>> "SW" == Stephen Weigand <weigand.stephen at gmail.com>
>>>>> on Tue, 31 Mar 2009 18:33:05 -0500 writes:
SW> I wonder if the 'sep' argument in reshape() is being ignored
SW> unintentionally:
No. It is used much differently than you *assume* it's used.
As always, ?reshape contains the answer.
SW> ## From example(reshape)
SW> df <- data.frame(id=rep(1:4,rep(2,4)),
SW> visit=I(rep(c("Before","After"),4)),
SW> x=rnorm(4), y=runif(4))
SW> reshape(df, timevar="visit", idvar="id", direction="wide", sep = "_")
SW> id x.Before y.Before x.After y.After
SW> 1 1 0.773 0.293 -0.021 0.658
SW> 3 2 -0.518 0.351 -0.623 0.946
SW> 5 3 0.773 0.293 -0.021 0.658
SW> 7 4 -0.518 0.351 -0.623 0.946
SW> Is this more of the intended result when 'sep = "_"'?
SW> id x_Before y_Before x_After y_After
SW> 1 1 0.773 0.293 -0.021 0.658
SW> 3 2 -0.518 0.351 -0.623 0.946
SW> 5 3 0.773 0.293 -0.021 0.658
SW> 7 4 -0.518 0.351 -0.623 0.946
no it is not.
I tend to agree that I would have preferred a different argument
name than 'sep' for the current 'sep',
and then a *further* argument 'sep' with the functionality that
you'd like would be straightforward.
Martin Maechler, ETH Zurich
More information about the R-devel
mailing list