Re: [R] Vector Join

From: Paul Smith <phhs80_at_gmail.com>
Date: Sun 13 Aug 2006 - 22:34:01 EST

On 8/13/06, Michael Zatorsky <miczat@yahoo.com> wrote:
> I'm working on producing a simple cumulative frequency
> distribution.
>
> Thanks to the help of the good people on this list I
> now have four vectors that I'd like to join/relate
> into a table. e.g.
>
>
> v1 <- myHistogram$breaks # classes
> v2 <- myHistogram$counts # freqs
> v3 <- cumsum(v2) # cumulative freq
> v4 <- ((v3 / length(myData)) * 100) # cumulative %
>
>
> What is the recommend approach to turning these into a
> single table with four columns? ie effectively doing
> a relational join on row id?
>
> The goal is to ultimately have the data with one row
> per class in a format I can write out to a text file
> as:
>
> v1 v2 v3 v4
> v1 v2 v3 v4
> etc...
>
> Any advice will be appreciated.

An example follows:

> V1 <- 1:4
> V2 <- 3:6
> V3 <- 2:5
> m <- matrix(nrow=4,ncol=3)
> m

     [,1] [,2] [,3]

[1,]   NA   NA   NA
[2,]   NA   NA   NA
[3,]   NA   NA   NA
[4,]   NA   NA   NA

> m[,1] <- V1
> m[,2] <- V2
> m[,3] <- V3
> m

     [,1] [,2] [,3]

[1,]    1    3    2
[2,]    2    4    3
[3,]    3    5    4
[4,]    4    6    5

>

Paul



R-help@stat.math.ethz.ch 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. Received on Sun Aug 13 22:38:02 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 14 Aug 2006 - 00:19:38 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.