I am trying to get my code to run in R and I keep running into the error message NA/NaN/Inf in foreign function call (arg 6) and 2 NAs introduced by coercion error messages