There are multiple post in the internet regarding the differences and similarities about [
and $
. I see some post where $
is recommended only for interactive use but not for programming. However, I am not sure I understand if this is a preference or there is an explanation behind this idea.
Now lets say I am writing a package or function, if I am extracting an element by name (e.g., mtcars[["mpg"]]
) why I should avoid using mtcars$mpg
?