To remove a row from a dataframe in R, you can use the subset()
function to create a new dataframe that excludes the row you want to remove. Another way is to use the indexing operator [ ]
to remove the row in-place.
Here's an example using the mtcars
dataset in R:
main.r395 chars11 lines
In Method 2, we specified -1
to remove the row with index 1. Similarly, you can specify any row index that you want to remove.
gistlibby LogSnag