test.df <- data.frame(col1 = c(1,2))
test.df[,character(0)] * test.df$col1
GNU-R:
data frame with 0 columns and 0 rows
fastR:
Error in rep.int(seq_len(ncol(e1)), rep.int(nrow(e1), ncol(e1))) :
invalid 'times' value
purpose for these code is to process column without worry about column existence, for example
test.df <- data.frame(col1 = c(1,2))
column.process <- 'no_such'
column.selected <- colnames(test.df)[ column.process %in% colnames(test.df)]
test.df[,column.selected] <- test.df[,column.selected] * test.df$col1
# test.df didn't change