0

I want to regroup this two variables R (votefr, voteaut) together how can i do it? To have in fine only one variable with the french vote and the austrian vote (maybe votefraut). (below the table of this two variables)

table(d$votefr)

Centre-droite Extreme-droite         Gauche 
           455            117            356 

table(d$voteaut)

 Centre-Droite Extreme-Droite         Gauche 
           424            208            545 

the result that i want is: table(d$votefraut) Centre-Droite Extreme-Droite Gauche 879 325 901

Edgar16
  • 1
  • 2
  • 1
    We could just add them? `table(d$votefr) + table(d$voteaut)` What is the expected output? – zx8754 Apr 14 '21 at 15:39
  • 1
    What is the expected output? Please provide reproducible example https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – zx8754 Apr 14 '21 at 15:51

2 Answers2

1

If you want to sum up all votes across different countries, you can try

Reduce(`+`, Map(table, df))

Otherwise, you can check table(df)

ThomasIsCoding
  • 80,151
  • 7
  • 17
  • 65
0

If both columns are factors with the same levels, we can just add them:

table(d$votefr) + table(d$voteaut)

If they are character class or factor with different levels, we need convert them to factors with the same levels.

zx8754
  • 46,390
  • 10
  • 104
  • 180
  • It's not the table that i want regroup, but the variable votefr and the variable voteaut. To have the distribution of the voters of this two countrys togheter – Edgar16 Apr 14 '21 at 15:51