I have a data frame like this:
df = data.frame(a=1:3, b=2:4, c=3:5)
I am selecting columns from that data frame using something akin to:
Also without the comma, i.e. df[c(T,F,F)], returns a dataframe but it sounds like you have cases where the new dataframe can have one or more columns. So use the drop option abovee
This one is pretty simple. Append , drop = FALSE
to your subsetting.
E.g.
df[, c(T, F, F), drop = FALSE]
Also works for matrices.