matching tables

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

matching tables

Eric Pante
Dear Listers,

I am trying to match tables that DO NOT have the same length. The
tables result from the function "table()" so they look like this:

table 1
2 3 4
3 5 7

table 2
1 2 3
6 4 5

I need the following output: (NOTICE THE ZEROS)
             1 2 3 4
table1 0 3 5 7
table2 6 4 5 0

Unfortunately, I was not successful using "match()". Previous postings
explain how to do similar matching, but for tables for same length,
specifically. Any thoughts ?

Thanks !
eric

Eric Pante
----------------------------------------------------------------
College of Charleston, Grice Marine Laboratory
205 Fort Johnson Road, Charleston SC 29412
Phone: 843-953-9190 (lab)  -9200 (main office)
----------------------------------------------------------------

        "On ne force pas la curiosite, on l'eveille ..."
        Daniel Pennac

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

Re: matching tables

bogdan romocea
t1 <- as.data.frame(table(1:10)) ; colnames(t1)[2] <- "A"
t2 <- as.data.frame(table(5:20)) ; colnames(t2)[2] <- "B"
t3 <- merge(t1,t2,all=TRUE)


> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Eric Pante
> Sent: Tuesday, February 07, 2006 4:22 PM
> To: [hidden email]
> Subject: [R] matching tables
>
> Dear Listers,
>
> I am trying to match tables that DO NOT have the same length. The
> tables result from the function "table()" so they look like this:
>
> table 1
> 2 3 4
> 3 5 7
>
> table 2
> 1 2 3
> 6 4 5
>
> I need the following output: (NOTICE THE ZEROS)
>              1 2 3 4
> table1 0 3 5 7
> table2 6 4 5 0
>
> Unfortunately, I was not successful using "match()". Previous
> postings
> explain how to do similar matching, but for tables for same length,
> specifically. Any thoughts ?
>
> Thanks !
> eric
>
> Eric Pante
> ----------------------------------------------------------------
> College of Charleston, Grice Marine Laboratory
> 205 Fort Johnson Road, Charleston SC 29412
> Phone: 843-953-9190 (lab)  -9200 (main office)
> ----------------------------------------------------------------
>
> "On ne force pas la curiosite, on l'eveille ..."
> Daniel Pennac
>
> ______________________________________________
> [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
>

______________________________________________
[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