qmd not rendering; RStudio giving error on incorrect code

I think that we probably need to see the the original document or a reduced version of it pasted here. See FAQ: Tips for writing R-related questions for some suggestions.