Null-Hypothesis Null-Hypothesis - 1 year ago 108
R Question

R data frame remove column using grep - columns don't get remove

I have following loop: <- c('C_', 'WWTest_', 'TotalClick', 'IPA_', 'Sell', 'G_')
for (i in length( {

final.frame <- final.frame[, -grep([i], colnames(final.frame))]

But when i look at the data frame by trying to do
its still shows up as all.

Answer Source
for (i in {
    final.frame <- final.frame[!grepl(i, colnames(final.frame))]

Edit: Doing this without a loop <- paste(, collapse = '|')
final.frame <- final.frame[!grepl(, colnames(final.frame))]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download