Q:

How to transpose groups of rows into

I want to transpose groups of rows into groups of columns.  But I do not want them on top of each other.  I want the result next to each other. 
THis is the data:
YEAR,RACE,0years,1years,2years
2016,White,c2,d2,e2
2016,Black,c3,d3,e3
2016,Native,c4,d4,e4
2017,White,c5,d5,e5
2017,Black,c6,d6,e6
2017,Native,c7,d7,e7
2018,White,c8,d8,e8
2018,Black,c9,d9,e9
2018,Native,c10,d10,e10
2019,White,c11,d11,e11
2019,Black,c12,d12,e12
2019,Native,c13,d13,e13
2020,White,c14,d14,e14
2020,Black,c15,d15,e15
2020,Native,c16,d16,e16

I tried excel, and pivot tables, but the data set is too large.  Above is just a summarized example.  Below the result I expect.   I have used R but I don't know where to start with this different formatting
,0years,0years,0years,1years,1years,1years,2years,2years,2years
,White,Black,Native,White,Black,Native,White,Black,Native
2016,c2,c3,c4,d2,d3,d4,e2,e3,e4
2017,c5,c6,c7,d5,d6,d7,e5,e6,e7
2018,c8,c9,c10,d8,d9,d10,e8,e9,e10
2019,c11,c12,c13,d11,d12,d13,e11,e12,e13
2020,c14,c15,c16,d14,d15,d16,e14,e15,e16

A:

Here is the tidyr option. 
library(tidyverse)
df1 %>% 
  gather(key, value, -(RACE:YEAR)) %>% 
  unite(new_col, key, RACE, sep = "_", remove=T) %>% 
  spread(new_col, value)

