How to refer to a data table column that has a name that is a number?

I have a dataframe (let's call it df) that contains the following types of data:

quantile   '1980'  '2000'
0          -2.36   -1.70
0.01       -2.35   -1.64
0.02       -2.35   -1.54

and so on...

I want to be able to refer to the columns but, for example, using df$1980 is not valid.

Use backticks:

df$`1980`

Or you can use list indexing:

df[[1980]]

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.