Reputation: 1922
library(tidyverse)
view first 15 records in starwars dataset
head(starwars, 15)
remove the 10th record ("Obi-Wan Kenobi"), based on position in the vector "Obi-Wan Kenobi" is in the 10th position
starwarsNames <- unique(starwars$name)[-10]
remove the 10th record ("Obi-Wan Kenobi"), based on value in the vector I see Error in -"Obi-Wan Kenobi" : invalid argument to unary operator when I attempt the following:
starwarsNames <- unique(starwars$name)[-"Obi-Wan Kenobi"]
Upvotes: 1
Views: 61
Reputation: 887118
We can use setdiff
setdiff(unique(starwars$name), "Obi-Wan Kenobi")
Or another option is logical
un1 <- unique(starwars$name)
un1[un1 != "Obi-Wan Kenobi"]
Upvotes: 1