I'm also on Mac (2011 Airbook) and I have Anaconda, which I use for Python and really like. But, I fear, you're asking for trouble to rely on it as an R package manager for source compilation.
My suggestion is to go into your .bash_profile and demote Anaconda in your $PATH precedence to make sure that vanilla XCode will get the first crack at compilation. Not that this will necessarily solve all your problems, but it will eliminate figuring out how to find the right version of stdlib.h and the right place to put it in order to make Anaconda successful.
Another suggestion. Unless you are really jammed for RAM memory use
install.packages("tidyverse")
library(tidyverse)
to bring in all the wonderful facilities that you will often use.
I just ran your install and none of them required compilation, so you're losing the advantage of the volunteers who have sweated out the OSx compilation details.
FWIW: I seldom have source installation problems under Ubuntu 10.18.