What I know so far ...
1) Backticks are used when creating tibbles with non-syntactic variable/column names that contain numbers, spaces, or other symbols (because normally you can only name columns with letters right?)
tb <- tibble(
': ) ' = "smile, ' ' = "space",
'2000' = "number", "double_quotes" = "normal_text")
However, when I use double quotes here the tibble still forms with the nonsyntactic symbols/numbers.
2) Double quotes are used to subset column names when using double brackets.
tb[["double_quotes"]]
And here, when I use single quotes to subset, it still works as well.
3) When subsetting using $, to select for nonsyntactic names, I must use single quotes, but here again, if I subset using double quotes, it works as well
Again, tb$": )" works just as well as tb$': )'
So are they effectively interchangeable?
Interestingly, when I plot a graph
annoying <- tibble(
`1` = 1:10,
`2` = `1` * 2 + rnorm(length(`1`))
)
ggplot(annoying, aes(x = `1`, y = `2`)) +
geom_point()
Single quotes must be used when referring to the nonsyntactic variables because otherwise, it looks like ggplot treats X and Y as single points of 1 and 2 respectively. Are there any other cases like this?