Looking at the code for [.data.frame , it gives this as part of the code
if (anyDuplicated(cols)) names(y) <- make.unique(cols)
and I could not see anything in the code that would allow me to skip this check. Looks like we just need to write our own function. It is not very safe, although I'm sure a much better version can be created ...
dropCols <- function(x, cols){ nm <- colnames(x) x <- x[, -cols] colnames(x) <- nm[-cols] x } x <- data.frame(b= 4:6, a =6:8, a =6:8, check.names = FALSE)
Dason source share