-1

I'm looking to be able to delete a row from a data frame already uploaded to r. I tried using the "select(Dataframe, -c(...)" function part of the dplyr package but this only deletes columns and not rows.

library(dplyr)
WallyceEdited <- select(X0626Wallyce,-c(Intensity,Signal, Ambient))

head(WallyceEdited)

The code used above is great for deleting columns, but I am wondering if there is a similar function I can use in dplyr or tidyverse to delete rows, not just columns.

joran
  • 169,992
  • 32
  • 429
  • 468
Nicole Step
  • 1
  • 1
  • 1
  • Are you looking for `?dplyr::filter` or `?dplyr::slice` maybe? – markus Jul 10 '19 at 19:40
  • Are you trying to delete based on a condition or position? Both should be covered thoroughly on SO, but which one you need will help point you to previous posts – camille Jul 10 '19 at 19:44

1 Answers1

2

This removes the third row where BOD is a builtin data frame with 6 rows that comes with R:

library(dplyr)
BOD %>% slice(-3)

giving this 5 row data frame:

  Time demand
1    1    8.3
2    2   10.3
3    4   16.0
4    5   15.6
5    7   19.8
G. Grothendieck
  • 254,981
  • 17
  • 203
  • 341