Say, I have a dataframe df
in R as follows,
id inflam
1 1 0.03093764
2 2 0.50115406
3 3 0.82153770
4 4 0.01985961
5 5 0.04994588
6 6 0.91714810
7 7 0.83438400
8 8 0.80832225
9 9 0.12360681
10 10 0.08490079
I can access the entirety of the inflam
column by indexing as df[,2]
or df[2]
. However, typeof(df[,2])
returns double
, whereas typeof(df[2])
returns list
. The comma seems to be the differentiator, but why is this the case? What is going on under the hood?