I agree with @ssdecontrol that a minimal reproducible example would be the most helpful. However, looking at your code (pay attention to the sequence
Error: ... Warning: ...), I believe that the issue you are experiencing is due to an inappropriate setting of R's global
warn option. It appears that your current setting is likely
2, which refers to converting warnings to errors, whereas, you, most likely want the setting
1, which is to treat warnings as such, without converting them to errors. If that is the case, you just need to set the option appropriately:
options(warn=1) # print warnings as they occur
options(warn=2) # treat warnings as errors
Note for moderators/administrators: This question seems not to be a data science question, but purely an R question. Therefore, I think it should be moved to StackOverflow, where it belongs.