Use drop=FALSE
> x <- df[,1, drop=FALSE]
> x
A
1 10
2 20
3 30
From the documentation (see ?"["
) you can find:
If drop=TRUE the result is coerced to the lowest possible dimension.
Use drop=FALSE
> x <- df[,1, drop=FALSE]
> x
A
1 10
2 20
3 30
From the documentation (see ?"["
) you can find:
If drop=TRUE the result is coerced to the lowest possible dimension.