I have the following code (Note don't flame me it's not my code I'm fixing a issue that I discovered in modification to this code.)
<!--begin.rcode echo=FALSE, results='asis', message=FALSE
overLevel <- 0
step <- 10
for(i in seq(1, nrow(exposures), by=step)) {
tryCatch({
tmp <- exposures[i:(i+step-1),]
cols <- ifelse( (as.numeric(gsub(",","",gsub(" ","",tmp$ARExcess)))) > overLevel, 'tomato',
ifelse(as.numeric(gsub(",","",gsub(" ","",tmp$MTMExcess))) > overLevel, 'lightyellow',
ifelse(as.numeric(gsub(",","",gsub(" ","",tmp$VolumeExcess))) > overLevel, 'azure3', 'white')))
cat(paste0('<h4><u>Exposures</u></h4>'))
cat(htmlTable(as.matrix(tmp), col.rgroup = cols, rnames = FALSE))
},error = function(e) {print(e)})
}
end.rcode-->
The problem I'm having is it's taking 10 items at a time(the for line in the code) from the excesses dataset and putting them into a tmp dataset 10 records at a time. When there is less than 10 records it drops and does not add the additional items to the RHTML file either resulting in a incomplete report or no report depending on records.
How would I be able to complete all records no matter if there are 10 or not. It needs to be in 10 chuck size for the readability in email (business rule) so I'm OK with it being 10 then on the last one being shorter but don't know how to do the last part.
Does anyone know how I can fix this or lend a helping hand?