r-intro-geospatial
r-intro-geospatial copied to clipboard
Always use comma notation for subsetting data frame columns
trafficstars
Lines L315:L325 in Lesson 5 advocate for subsetting columns without comma notation:
head(gapminder[3])
I'd argue that for clarity sake, we should change this to always use comma notation:
head(gapminder[,3]
See #86
I disagree with this suggestion because the objects returned by each operation are different:
> class(gapminder[3]) == class(gapminder[ ,3])
[1] FALSE
>
> mode(gapminder[3]) == mode(gapminder[ ,3])
[1] FALSE
>
> typeof(gapminder[3]) == typeof(gapminder[ ,3])
[1] FALSE
However, both objects contain the same values:
> all(gapminder[3] == gapminder[ ,3])
[1] TRUE
For beginners, or even experts, this subtle change could go unnoticed and produce unexpected consequences.
For that reason, I think it's better to close this issue without implementing the suggested changes.