added NA test cases, made sure those cases are handled in the output. passes R CMD Check