Why might one prefer using one of the following approaches to reference columns in a data.frame when writing functions inside an R package?
d <- data.frame(x = c(1, 2))
# This is one way to extract a column from a data.frame.
# Using dollar sign notation
d$x
#> [1] 1 2
# This is another way to extract a column from a data.frame
d[["x"]]
#> [1] 1 2
Created on 2021-04-19 by the reprex package (v1.0.0)
I vaguely remember reading that the second approach is preferable when programming with R, but I don't remember why. The dollar sign approach is more concise, so ceteris paribus, I would rather use the dollar sign approach.