How do I delete rows from a data frame when the DF only has one column [duplicate]

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.

Browse More Popular Posts

Leave a Comment