Error in instaling ggplot2 on rstudio 1.2.1335 on a macOS Mojave version 10.14.5

Are you getting the exact same error message? because this part suggests that you don't have xcode properly installed in your system.