For a package I am currently writing I have to subset rows of a dataframe, which can have 1 or more columns. After hours of debugging I found out that R deals differently when a data.frame has one column as opposed to more:
df1 <- data.frame(col1 = c(1, 2, 3), col2 = c(2, 3, 4))
df2 <- data.frame(col1 = c(1, 2, 3))
class(df1[1, ])
#> [1] "data.frame"
class(df2[1, ])
#> [1] "numeric"
This is so annoying and I would have to implement if-statements to take care of this, which I don't want to. Can someone tell my why that is, and how I turn it off?