I downloaded Xcode for mac because according to a blog I read, R needs to be in a dev environment to perform this installation. But not sure how to apply the dev environment to R?
You should not try to install packages from an Rmd document, the R session is waiting for you to choose an option but that is not possible on a code chunk, that is why it keeps loading without doing anything.
Package installation has to be done interactively on the R console.