regsubsets function in the leaps package finds
  optimal subsets of predictors. This function plots a measure of fit
  (see the statistic argument below) against subset size.
subsets(object, ...)
"subsets"(object,  names=abbreviate(object$xnames, minlength = abbrev),  abbrev=1, min.size=1, max.size=length(names),  legend="interactive",  statistic=c("bic", "cp", "adjr2", "rsq", "rss"),  las=par('las'), cex.subsets=1, ...)regsubsets object produced by the regsubsets function
    in the leaps package.object.1.FALSE, in which case the legend is suppressed,
    the coordinates at which to place a legend of the abbreviated predictor names on the plot, 
    in a form recognized by
    the legend function. If "interactive", the legend is placed on the
    plot interactively with the mouse. By expanding the left or right plot margin, you can place
    the legend in the margin, if you wish (see par)."bic", Bayes Information Criterion; 
    "cp", Mallows's $Cp$;
    "adjr2", $R^2$ adjusted for degrees of freedom;
    "rsq", unadjusted $R^2$;
    "rss", residual sum of squares.0, ticks labels are drawn parallel to the
    axis; set to 1 for horizontal labels (see par).1.subsets.regsubsets and plot.NULL if the legend is TRUE; otherwise a data frame with the legend.
regsubsetsif (require(leaps)){
    subsets(regsubsets(undercount ~ ., data=Ericksen),
            legend=c(3.5, -37))
}
Run the code above in your browser using DataLab