HOW TO CREATE A COUNTRY-YEAR DATA USING MUTATE

Viewed 32

The initial data is a time series data from Transparency International on countries’ level of corruption dating from 2012 to 2020 (CPI Score). It has a country name column, with a bunch of CPI Score columns by year (ex: CPI 2020, CPI 2012 etc). I wish to have 3 columns: 1 with the county names, one with the years and one with the corresponding CPI Score.

enter image description here

I wish to create a country-year dataset, from one that is not. I tried using the mutate function but I get this message error:

mutate(data, c("Year" = "CPI 2012", "CPI2013"), "CPI2014", "CPI2015", "CPI2016", "CPI2017", "CPI2018", "CPI2019", "CPI2020")

Error: Problem with mutate() input ..1. ℹ ..1 = c(Year = "CPI 2012", "CPI2013"). ℹ ..1 must be size 180 or 1, not 2.

Is it the right function to use? What can I do to fix it?

0 Answers
Related