Using only standard S-PLUS, I would use:
do.call("c", x[,-1]) # A data frame is also a list
or maybe
cbind(rep(x[,1], ncol(x)-1), do.call("c", x[,-1]))
Regards,
Henrik
On Thu, 16 Oct 2003, Sundar Dorai-Raj wrote:
> Would "reShape" in library(Hmisc) do what you need?
>
> x <- data.frame(id = 1:5)
> x$y4 <- x$y3 <- x$y2 <- x$y1 <- rnorm(5)
> reShape(x, base = "y", reps = 4)
>
> Hope this helps,
>
> -sundar
>
> Mathangi Gopalakrishnan wrote:
>
> > Hello
> > I have a dataframe with 7 rows and 5 columns. I want to write a s-plus
> > command to stack columns 2 to 5. In GUI i used the stack option to do
> > the same.
> > How do i write the command?
> > Could somebody help me on this?
> > Thank you
> >
> > Best Wishes,
> > Mathangi Gopalakrishnan
> >
> > _________________________________________________________________
> > Add MSN 8 Internet Software to your current Internet access and enjoy
> > patented spam control and more. Get two months FREE!
> > http://join.msn.com/?page=dept/byoa
> >
> > --------------------------------------------------------------------
> > This message was distributed by s-news@lists.biostat.wustl.edu. To
> > unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> > the BODY of the message: unsubscribe s-news
>
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu. To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message: unsubscribe s-news
>
|