Re: [Rd] 'sep' argument in reshape()

2009-04-01 Thread Martin Maechler
 SW == Stephen Weigand weigand.step...@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  10.7730.293  -0.021   0.658
SW 3  2   -0.5180.351  -0.623   0.946
SW 5  30.7730.293  -0.021   0.658
SW 7  4   -0.5180.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  10.7730.293  -0.021   0.658
SW 3  2   -0.5180.351  -0.623   0.946
SW 5  30.7730.293  -0.021   0.658
SW 7  4   -0.5180.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

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] 'sep' argument in reshape()

2009-04-01 Thread Thomas Lumley

On Tue, 31 Mar 2009, Stephen Weigand wrote:


I wonder if the 'sep' argument in reshape() is being ignored
unintentionally:

## From example(reshape)
df - data.frame(id=rep(1:4,rep(2,4)),
 visit=I(rep(c(Before,After),4)),
 x=rnorm(4), y=runif(4))

reshape(df, timevar=visit, idvar=id, direction=wide, sep = _)

 id x.Before y.Before x.After y.After
1  10.7730.293  -0.021   0.658
3  2   -0.5180.351  -0.623   0.946
5  30.7730.293  -0.021   0.658
7  4   -0.5180.351  -0.623   0.946

Is this more of the intended result when 'sep = _'?


No. sep= is designed for going the other way.  If you have wide-format data with variable 
names x.Before y.Before x.After y.After, using sep=. will let reshape() work 
out that the long-format variable names are x and y and the conditions to be put in the 
time variable are Before and After.

   -thomas


Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] 'sep' argument in reshape()

2009-03-31 Thread Stephen Weigand
I wonder if the 'sep' argument in reshape() is being ignored
unintentionally:

## From example(reshape)
 df - data.frame(id=rep(1:4,rep(2,4)),
  visit=I(rep(c(Before,After),4)),
  x=rnorm(4), y=runif(4))

reshape(df, timevar=visit, idvar=id, direction=wide, sep = _)

  id x.Before y.Before x.After y.After
1  10.7730.293  -0.021   0.658
3  2   -0.5180.351  -0.623   0.946
5  30.7730.293  -0.021   0.658
7  4   -0.5180.351  -0.623   0.946

Is this more of the intended result when 'sep = _'?

  id x_Before y_Before x_After y_After
1  10.7730.293  -0.021   0.658
3  2   -0.5180.351  -0.623   0.946
5  30.7730.293  -0.021   0.658
7  4   -0.5180.351  -0.623   0.946

Thanks,

Stephen
-- 
Rochester, Minn. USA

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel