read_neutropenia_data = function(){ fn = '../../Data/neutropenia.dat' tx = scan(file=fn, what='character', sep=NULL, quiet=TRUE) neu = data.frame(NULL) ## Read the first row: ## neu = rbind(neu, tx[1:4]) colnames(neu) = c('Dose', 'Use_G_CSF', 'Neutropenia_cases', 'Treatment_courses') tx = tx[-(1:9)] ## remove the first. row (with header information) ## Read the rest of the rows: ## while( length(tx) > 0 ){ df = data.frame(t(tx[1:4])) colnames(df) = c('Dose', 'Use_G_CSF', 'Neutropenia_cases', 'Treatment_courses') neu = rbind(neu, df) tx = tx[-(1:4)] } ## Cast the variables: ## neu$Dose = as.numeric(neu$Dose) neu$Neutropenia_cases = as.numeric(neu$Neutropenia_cases) neu$Treatment_courses = as.numeric(neu$Treatment_courses) neu$Use_G_CSF = as.factor(neu$Use_G_CSF) return(neu) }