brucezepplin
brucezepplin

Reputation: 9752

R - appended columns from different tables

I have 10 tables (2 columns) which share a common column (second column) and the first columns of each table holds information for years 2000-2010. Like this

Table1

Amount2000    Percentage
3             80-100
9             60-80
14            40-60
9             20-40
0             0-20

Table2

Amount2001    Percentage
3             80-100
9             60-80
14            40-60
9             20-40
0             0-20

etc.

What I want to do is create a table like the following:

Percentage   Amount2000  Amount2001   Amount2002.......
.
.
.

by using cbind perhaps? What is the best way of doing this? Thanks!

Upvotes: 0

Views: 55

Answers (1)

Alan
Alan

Reputation: 3203

Try merge(Table1,Table2) in a loop for merging Table1-10. If each Percentage sections has the same length and are in the same order try cbind(Table1[,2:1],Table2[,1],Table2[,1],...).

Upvotes: 1

Related Questions