Error in contrib.url(repos, "source") :

There's discussion on this reply helping diagnose the issue.

What happens when you take cderv's advice there?

That is,

This is not an error with Rmarkdown, it is an error with R saying you don't have any CRAN repo configure. If you have a call to install.package or else in your Rmd doc, it could cause the error.

Just configure a cran mirror if you haven't one. Are you using RStudio IDE BTW?