Collums does not excit

Relativly new to R. Getting this message. Trying to make a geom line and get this message when I try to piovot the table from short to long.

Error in build_longer_spec():
! Can't subset columns that don't exist.
:heavy_multiplication_x: Column 2000 doesn't exist.
Backtrace:

  1. ... %>% ...
  2. tidyr:::pivot_longer.data.frame(...)
  3. tidyr::build_longer_spec(...)

Please provide the code that leads up to the error and a little data we can use with the code. To provide the data, you can post the output of the dput() function. If your data frame is named DF, run

dput(head(DF,20))

to provide the first 20 rows of data. Put the output of dput() between lines with three back tickes, like this:
```
output of dput() goes here
```

GDP data

EU data

Transforming from wide to short

eu_gdp <- eu_gdp %>%
mutate_if(is.numeric,as.character, is.factor, as.character) %>%
pivot_longer(
cols = c('2000':'2020'),
names_to = "Year",
values_to = "gdp_n3")

Renaming geo column

  eu_gdp <- rename(eu_gdp, "id_nuts3" ="GEO (Codes)" )
  
# Keep relevant vars
  eu_gdp <- eu_gdp %>% select("id_nuts3", "Year","gdp_n3")

UK data

Transforming from wide to short

uk_gdp <- uk_gdp %>%
mutate_if(is.numeric,as.character, is.factor, as.character) %>%
pivot_longer(
cols = c('2000':'2020'),
names_to = "Year",
values_to = "gdp_n3")

Renaming geo column

  uk_gdp <- rename(uk_gdp, "id_nuts3" = "ITL code")  
  uk_gdp <- rename(uk_gdp, "GDP_pound" = "gdp_n3")
  
#Exchange Pund to Euro
  uk_gdp %<>% mutate("gdp_n3" = as.numeric(uk_gdp$GDP_pound)/1.16)
# Keep relevant vars
  uk_gdp <- uk_gdp %>% select("id_nuts3", "Year","gdp_n3") 

# Merge UK and EU data    
GDPall <- rbind(uk_gdp, eu_gdp)

# Converting from GDP in millions to GDP in hundred thousand
GDPall <- GDPall %>% 
mutate("gdp_n3" = as.numeric(GDPall$gdp_n3) * 10)

I am wondering if it has something to do with the years being used as a category. If it is reading it as a number. Are you advanced in R. I could really need some help as I am pushed for time. Actually not so sure about what I am doing. I know what I want done. :laughing:

Please post a little of your data. Run

dput(head(eu_gdp,10))

and post the output as explained in my last post.