Suppose I have data table:
V = data.table('x'=0, 'price1'=1:10, 'price2'=10:1)
I want to return this:
price1 price2
1: 1 10
2: 2 9
3: 3 8
4: 4 7
5: 5 6
6: 6 5
7: 7 4
8: 8 3
9: 9 2
10: 10 1
But
j=1:J
V[,get(paste0('price',j))]
Does not work. I need J to be arbitrarily long, so please do not provide a workaround that directly indexes or indexes by column number, because these are both not feasible with my data because it is designed to be general. I want to call these columns by name using compact notation for an arbitrarily number of columns.