Answers for "R drop columns"

R
2

drop columns by index r

#drop columns by index
df <- mydata[ -c(1,3:4) ]
#drop columns by name
df = subset(mydata, select = -c(x,z))
Posted by: Guest on November-13-2020
-1

R drop columns

undesired <- c('mpg', 'cyl', 'hp')

mtcars <- mtcars %>%
  select(-one_of(undesired))
Posted by: Guest on November-16-2020

Browse Popular Code Answers by Language