I'm working with a time-series tibble that is organized in the following way:
Country<- ('Somalia')
'1961'<- 2999
'1962'<- 2917
'1963'<- 1853
df <- data.frame(Country, `1961`, `1962`, `1963`)
df
The problem is that is extremely hard to work with data organized in such a way, since that the only way to access the data that I want (those numbers that are under the column names) is by referring to each year individually. Is there a simple way to organize them in a tidy way, such as:
x <- 'Somalia'
y <- c('1961', '1962', '1963')
z <- c(2999, 2917, 1853)
df <- data.frame(x, y, z)
df
Without having to manually rebuild the entire dataset?