Skip to content
Back to formatted view

Raw Message

Message-ID: <F7E6D18CC2877149AB5296CE54EA27660EF3C26F@WAXMXOLYMB010.WAX.wa.lcl>
Date: 2013-02-15T01:19:40Z
From: Nordlund, Dan (DSHS/RDA)
Subject: How to stack row vector on top of each other?
In-Reply-To: <CAE2FW2nJh3h_seZo_FZcDO4vddeG9ghVpjPaOUAysvH6-9vO8g@mail.gmail.com>

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of C W
> Sent: Thursday, February 14, 2013 5:08 PM
> To: r-help
> Subject: [R] How to stack row vector on top of each other?
> 
> Hi list,
> How do you actually stack a vector on top of each other?  Say, I want
> everything in a row vector.  Neither rbind(), nor cbind() will do the
> job.
>  It gives me 2 dimension.
> 
> Here's my reproducible example:
> > a <- rnorm(10)
> > b <- rnorm(10)
> > c <- cbind(a,b)
> > dim(c)
> [1] 10  2
> 
> > d <- rbind(a,b)
> > dim(d)
> [1]  2 10
> 
> Thanks,
> Mike

I guess I don't know what you mean by "actually stack a vector on top of each other".  Given the vectors 

a <- 1:3
b <- 4:6

What result do you want from "stacking" a and b?


Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204