I want to write a general script to find the information gain of a set of functions relative to the last column. For example, in a data frame built from a matrix with 26 columns, I would write:
information.gain(V26~.,table)
The problem is that the formula is V26 ~. does not have an obvious general form. My first thought was to try the following:
> nms <- colnames(table) > nms[length(nms)] [1] "V26" > information.gain(nms[length(nms)]~., table) Error in model.frame.default(formula, data, na.action = NULL) : variable lengths differ (found for 'V1')
which seemed wrong due to the fact that nms is a row vector. Is there a way to force the name to something that can be part of the formula?
source share