I am dealing with cross-country time series with character variables:
Country_name Year Policy_area Type
<chr> <dbl> <chr> <chr>
1 Antigua and Barbuda 2012 FIN SB
2 Antigua and Barbuda 2011 RTP SB
3 Antigua and Barbuda 2012 RTP SB
4 Antigua and Barbuda 2012 FP SB
5 Antigua and Barbuda 2010 INS SB
6 Antigua and Barbuda 2011 DEB SB
7 Antigua and Barbuda 2012 TRANS SB
8 Antigua and Barbuda 2012 RTP SB
9 Antigua and Barbuda 2011 SOE SB
10 Antigua and Barbuda 2013 SOE SB
… with 2,740 more rows
I need to transform this data into a wide format and modify character variables to numeric by counting them (names for new columns would become: FIN_SB, RTP_SB, FP_SB, DEB_SB, TRANS_SB, SOE_SB, FIN_SPC, FIN_PA, etc.).
Do you know any code that could help me count how many times each policy area (FIN, RTP, FP, INS, etc.) of a specific type (SB, SPC, PA) appears per year for each country?
Thank you in advance!