This is sort of a duplicate of this question, but the emphasis is very different, so I'm posting it.
I have a data.frame with one column. If I attempt to delete a row using "df[-1, ]" R returns a List. How do I get it to return a data.frame?
This is sort of a duplicate of this question, but the emphasis is very different, so I'm posting it.
I have a data.frame with one column. If I attempt to delete a row using "df[-1, ]" R returns a List. How do I get it to return a data.frame?
The problem is that R is trying to be "helpful", and simplifying your data for you. The solution is to do the following (note two commas, not one):
df[-1,, drop = FALSE]
This will remove the specified row, and leave your data.frame otherwise untouched.