0
autompg = read.table( "http://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data", quote = "\"", comment.char = "", stringsAsFactors = FALSE)`
`head(autompg,20)`
`colnames(autompg) = c("mpg", "cyl", "disp", "hp", "wt", "acc", "year", "origin", "name")

Complete the code segment below to remove samples with the name “plymouth reliant”

I've tried executing the statement

autompg = autompg %>%select(-'plymouth reliant')

However, it says that "Can't subset columns that don't exist." So, I realised that the function is used to remove columns and not samples or rows. Then, I tried executing

rlang::last_trace()

As per its suggestion, I tried executing the code

autompg = autompg %>%dplyr::select(,-"plymouth reliant")

And yet, it says "Can't subset columns that don't exist."

Ankita
  • 1
  • 3
  • 3
    You can use `dplyr::filter()` to retain and exclude rows based on a condition. `autompg %>% dplyr::filter(name != "plymouth reliant")` – Seth Jun 12 '23 at 19:56
  • 1
    This cheatsheet is pretty useful: https://posit.co/wp-content/uploads/2022/10/data-transformation-1.pdf – slothrop Jun 12 '23 at 20:07

0 Answers0