get_birthwt_data = function(){ fn = '../../Data/birthwt.dat' DF = read.table(fn, header=FALSE, skip=0, col.names=c('head', 'length', 'gage', 'wt', 'momage', 'pre.ecl'), fill=TRUE) DF$pre.ecl = factor(DF$pre.ecl, levels=c(0, 1), labels=c('No', 'Yes')) ## Make the output 'weight' the last column of the data frame (I think this is the most common output): ## wt = DF$wt DF$wt = NULL DF$wt = wt DF[is.na(DF)] = 0 DF }