Accessing the i
th element in the column bar
in the dataframe foo
in R can be done in two different ways:
foo[i,"bar"]
and
foo$bar[i]
.
Is there any difference between them? If so, which one should be used in terms of efficiency, readability, etc.?
Apologies if this has already been asked, but []
and $
characters are very elusive.