Consider a data frame with custom row names:
> data <- data.frame(a=1:3,b=2:4,c=3:5,row.names=c(\"x\",\"y\",\"z\")) > data a b c x 1 2 3 y 2 3 4 z 3 4
You can use the drop argument (see also ?'['):
drop
?'['
data[,"c", drop=FALSE]
gives you a data.frame
data.frame
c x 3 y 4 z 5
An even easier way is data['c'], which will result in the same output:
data['c']