Demand.Residence <- function(Projection, type){
        
        #The number of columns in projection input file
        Columns <- ncol(Projection)
        
        #The last column with projection data
        last.col <- Columns-5
        
        #The column containing the number of children at independent school
        indep.pop.col <- which(colnames(Projection)=="Indy.Pop")
        indep.pc.col <- which(colnames(Projection)=="Indy.pc")
        
        #Loop through each year of the projection and
        #subtract pupils expected to be at independent school
        
        #If type is set to absolute then this a constant value each year
        #If type set to rate then value is a proportion of the total population
        
        state <- select(Projection,1)
        independent <- select(Projection,1)
        
        for(i in 2:last.col){
                
                if(type=="abs"){state[i] <- Projection[i]-Projection[indep.pop.col]}
                
                if(type=="rate"){state[i] <- Projection[i]-((Projection[indep.pc.col]/100)*Projection[i])}
        }
        
        for(i in 2:last.col){
                
                independent[i] <- Projection[i] - state[i]
        }
        
        return(list(state,independent))
        
}