The dataset is table2 in the tidyr package.
Here is the code.
library(tidyr)
#Converting a wide dataset into long dataset
long_data <- gather(table2,
key="variable",
value="value",
year:count)
as.data.frame(long_data)
#Converting the above long data set to a wide dataset again
wide_data <- spread(long_data, variable, value) -----> This is where I'm facing errors.