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
Dharman
  • 30,962
  • 25
  • 85
  • 135
Edgar16
  • 11
  • 1
  • 3
  • 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
  • 96,636
  • 9
  • 24
  • 81
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
  • 52,746
  • 12
  • 114
  • 209
  • 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