I have a datatable with several numeric colum names, for instant 2020-4 and 2020-5. That I refer to as Nouvelle_periode = "2020-5" and Ancienne_periode = "2020-4"
I manage to do things on these columns by using get as mentioned here.
But to delete a column it does not seem to work :
This works: Test_2 <- Test[,Revision:=get(Nouvelle_periode) - get(Ancienne_periode)]
But this does not : Test_3 <- Test_2 [,get(Ancienne_periode):=NULL] (I get the error object 2020-4 not found, even if it is still 
And I have no idea why.
Here is a MWE :
library(data.table)
Nouvelle_periode = "2020-5"
Ancienne_periode = "2020-4"
Test <- data.table(Zone = c("Allemagne", "Allemagne", "Allemagne", 
  "Allemagne", "Espagne", "Espagne", "Espagne", "Espagne", "Etats-Unis", 
  "Etats-Unis", "Etats-Unis", "Etats-Unis", "France", "France", 
  "France", "France", "Italie", "Italie", "Italie", "Italie", "Japon", 
  "Japon", "Japon", "Japon", "Monde", "Monde", "Monde", "Monde", 
  "Royaume-Uni", "Royaume-Uni", "Royaume-Uni", "Royaume-Uni", "Zone euro", 
  "Zone euro", "Zone euro", "Zone euro"), Periode = c("2020", "2020", 
    "2021", "2021", "2020", "2020", "2021", "2021", "2020", "2020", 
    "2021", "2021", "2020", "2020", "2021", "2021", "2020", "2020", 
    "2021", "2021", "2020", "2020", "2021", "2021", "2020", "2020", 
    "2021", "2021", "2020", "2020", "2021", "2021", "2020", "2020", 
    "2021", "2021"), Grandeur = c("IPC", "PIB", "IPC", "PIB", "IPC", 
    "PIB", "IPC", "PIB", "IPC", "PIB", "IPC", "PIB", "IPC", "PIB", 
    "IPC", "PIB", "IPC", "PIB", "IPC", "PIB", "IPC", "PIB", "IPC", 
    "PIB", "IPC", "PIB", "IPC", "PIB", "IPC", "PIB", "IPC", "PIB", 
    "IPC", "PIB", "IPC", "PIB"), `2020-4` = c(0.7, -5, 1.4, 4.5, 
 -0.4, -5.7, 1.3, 5.2, 0.8, -4, 1.8, 3.9, 0.4, -5.4, 1.3, 5.1, 
 -0.2, -7.5, 0.6, 4.5, -0.1, -3.3, 0.2, 2.1, 2.1, -2.1, 2.4, 4.4, 
 1, -5.4, 1.6, 4.7, 0.4, -5.7, 1.3, 5.4), 
 `2020-5` = c(0.6, -6.3, 1.4, 5.2, -0.4, -9.1, 1, 6.7, 0.7, -5.4, 1.8, 4.3, 0.3, -8.2, 
1.2, 6.7, -0.2, -9.9, 0.6, 6.3, -0.4, -5.5, 0.1, 2.4, 2, -4.1, 2.3, 5.1, 1, -7.9, 1.4, 6.1, 0.3, -7.9, 1.1, 6.2))
Test_2 <- Test[,Revision:=get(Nouvelle_periode) - get(Ancienne_periode)]
Test_3 <- Test_2 [,get(Ancienne_periode):=NULL]
 
    