I'm struggling to achieve something supposedly simple. I have dataframe df with columns a and b. If I call df$a, df$"a" df$`a`, it works. So I'm thiking I can assign a variable a string, and then use that. But if I do and try to get the column with it, I get Unknown or uninitialised column.
df = data.frame(a=(1:3), b=c("a", "b", "c"))
df$a # works
df$`a` # works
df$"a" # works
x <- "a"
df$x # error
How to solve this?