On May 15, 2012, at 11:18 PM, Santosh wrote:
> Hello R/Splus users..
> I am posting in R discussion group in hope of wider response
> compared to
> what I received from Splus user groups....
>
> Was wondering if there is any function available in Splus 8.2 that is
> equivalent to "reshape" of R?
>
> Below is a sample dataset. Size [both rows and columns) of the
> dataset may
> vary
> X1 Y1 Y2 Y3
> 0.25 40 38 22
> 0.5 44 41 43
> 1 32 32 58
> 2 25 25 25
> 4 23 26 17
> 6 10 11 23
> 8 10 92 13
> 24 1.7 15 4.6
data.frame(id=rep(1:(length(dfrm)-1), each=NROW(dfrm)),
x= rep(dfrm[["X1"]], times= length(dfrm)-1),
y=unlist(dfrm[-1]) )
You could also just copy the code for reshape or stack and see if it
succeeds. the code for stack.data.frame has some preparatory steps but
finishes up with something very similar to above:
...
data.frame(values = unlist(unname(x)), ind = factor(rep.int(names(x),
lapply(x, length))), stringsAsFactors = FALSE)
--
David.
>
> and I would like to have them stacked.... as shown below..
> id x y
> 1 0.25 40
> 1 0.5 44
> 1 1 32
> 1 2 25
> 1 4 23
> 1 6 10
> 1 8 10
> 1 24 1.7
> 2 0.25 38
> 2 0.5 41
> 2 1 32
> 2 2 25
> 2 4 26
> 2 6 11
> 2 8 92
> 2 24 15
> 3 0.25 22
> 3 0.5 43
> 3 1 58
> 3 2 25
> 3 4 17
> 3 6 23
> 3 8 13
> 3 24 4.6
>
>
> Thanks..
> santosh
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT