How to stack row vector on top of each other?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to stack row vector on top of each other?

tmrsg11
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

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to stack row vector on top of each other?

Pascal Oettli-2
Hi,

Actually, ?"c"

 > a <- rnorm(10)
 > b <- rnorm(10)
 > d <- c(a,b)
 > length(d)
[1] 20

HTH,
Pascal


Le 15/02/2013 10:08, C W a écrit :

> 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
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to stack row vector on top of each other?

tmrsg11
Wow, thanks, I just wasn't thinking right.

I also figured this would do cbind(t(a), t(b)), but that's asking for more
work.

Mike

On Thu, Feb 14, 2013 at 8:17 PM, Pascal Oettli <[hidden email]> wrote:

> Hi,
>
> Actually, ?"c"
>
>
> > a <- rnorm(10)
> > b <- rnorm(10)
> > d <- c(a,b)
> > length(d)
> [1] 20
>
> HTH,
> Pascal
>
>
> Le 15/02/2013 10:08, C W a écrit :
>
>> 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
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________**________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide http://www.R-project.org/**
>> posting-guide.html <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to stack row vector on top of each other?

Nordlund, Dan (DSHS/RDA)
In reply to this post by tmrsg11
> -----Original Message-----
> From: [hidden email] [mailto:r-help-bounces@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


______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to stack row vector on top of each other?

Giovanni Petris
How about

c(a, b)

?

HTH,
Giovanni
________________________________________
From: [hidden email] [[hidden email]] on behalf of Nordlund, Dan (DSHS/RDA) [[hidden email]]
Sent: Thursday, February 14, 2013 7:19 PM
To: r-help
Subject: Re: [R] How to stack row vector on top of each other?

> -----Original Message-----
> From: [hidden email] [mailto:r-help-bounces@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


______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: How to stack row vector on top of each other?

Uwe Ligges-3


On 15.02.2013 16:37, Giovanni Petris wrote:
> How about
>
> c(a, b)

But then, if he is actually going to have a row vector, t() is needed -
and one may want to answer the OP who may not read this list ....

Best,
Uwe Ligges



>
> ?
>
> HTH,
> Giovanni
> ________________________________________
> From: [hidden email] [[hidden email]] on behalf of Nordlund, Dan (DSHS/RDA) [[hidden email]]
> Sent: Thursday, February 14, 2013 7:19 PM
> To: r-help
> Subject: Re: [R] How to stack row vector on top of each other?
>
>> -----Original Message-----
>> From: [hidden email] [mailto:r-help-bounces@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
>
>
> ______________________________________________
> [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.