0

I am wording with a dataset with 203 variables. I want to hide some of these variables that I am not using.

I noticed for an example with Iris, the person in the tutorial hide the class variable with Iris.feature$class<-NULL

Is there a way I can do the same to my data in one single line? some of the variables I want to hide: Address, Middlename, etc

testData.features$Address<-NULL

testData.features$Middlename <-NULL

What can I possibly do to hide all these variables without copying and pasting repetitively ?

s_baldur
  • 29,441
  • 4
  • 36
  • 69
David Luong
  • 413
  • 1
  • 6
  • 12
  • That doesn't hide them. That actually removes them from the data.frame permanently. You can negate a subset with something like `subset(iris, select=-c(Petal.Length,Petal.Width))` in base R, or you can use `select()` from dplyr with many more column selection options. – MrFlick Jun 25 '18 at 15:13
  • @MrFlick I *think* that OP is actually asking for removal (see title), and not for hiding, despite the ambiguous wording... – desertnaut Jun 25 '18 at 15:15
  • @Peter_Evan Thanks, your link helped a lot. I found it easier just using "dat <- dat[,c("col1","col2",...)]" and selecting which variables I actually need. tysm. – David Luong Jun 25 '18 at 15:24

0 Answers0