0

Create the dataframe taxis_smaller that excludes the columns VendorID, rate, and store_and_fwd_flag.

taxis_smaller <- taxis %>% select(taxis,-c("VendorID","rate","store_and_fwd_flag"))
 select(taxis,-c("VendorID","rate","store_and_fwd_flag"))
MrFlick
  • 195,160
  • 17
  • 277
  • 295
Sofia
  • 1
  • 1
    If you are piping in to `select`, don't repeat the data.frame name. Just use `taxis_smaller <- taxis %>% select(-c("VendorID","rate","store_and_fwd_flag"))` – MrFlick Feb 01 '20 at 05:36

1 Answers1

1

An alternate approach to - placement when piping select is:

taxis_smaller <- taxis %>% 
    select(-VendorID, -rate, -store_and_fwd_flag)
fredjaya
  • 63
  • 9
  • Are you saying you can't put a minus before a vector of names? `select(iris, -c("Sepal.Length", "Sepal.Width"))` seems to work just fine for me at least. I don't think you need to repeat the `-` a bunch of times. – MrFlick Feb 01 '20 at 06:07
  • That definitely works! I think the repeated `-` looks a bit cleaner than `-c(...)` when dealing with a few columns. – fredjaya Feb 01 '20 at 06:17