2

I have the following data.frame:

state           demvot      year         

Alabama          84         1932
Arizona          67         1932
Arkansas         86         1932
California       58         1932
*********************************
Alabama          63         1936
Arizona          51         1936
Arkansas         39         1936
California       55         1936

I want to set an index_col assinged as 'year' grouped by year (1932,1936,1940) and an index_row assigned as 'state', grouped by state (Alabama, Arakansas...) and inside the demVote.

An example as follows:

    state Alabama Arizona Arkansas California
year                  
1932      84       67      86        58
1936      70       35      ...
1940
1944

The programming language to be used must be r.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Roy
  • 19
  • 4
  • Please search this site (or the web) for `long format`and `wide format` and find tools like `reshape2` packages, `cast` and `melt` functions and many more approaches. Also please read about examples here: http://stackoverflow.com/help/mcve – Bernhard Mar 02 '17 at 10:38

0 Answers0