Anyway, I have often wished that something like
new.mt.sample <- miceTrainSample[, -"pID50"]
would return miceTrainSample without the pID50 column. Here are three
alternative ways to do it.
# Method 1: Assign NULL to the column
new.mt.sample <- miceTrainsSample
new.mt.sample$pID50 <- NULL
# Method 2: Use which()
new.mt.sample <- miceTrainSample[, - which(names(miceTrainSample == "pID50")]
# Method 3: use %in% (the one I usually use)
new.mt.sample <- miceTrainSample[, ! names(miceTrainSample) %in% "pID50"]
As a variation on Method 1...
df <- data.frame(a = 1:10, b = 2:11, c = 3:12)
transform(df, a = NULL)
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.