Download and install R base and Rtools.
Download R-x.x.x.pkg and install it.
You may need to install libxml2 with Homebrew:
brew install libxml2
Open R console and execute following code:
install.packages("data.table", type = "source",
repos = "https://Rdatatable.github.io/data.table")
pkgs = c("httr", "rvest", "DT", "rmarkdown", "XML", "whisker", "googleVis",
"leaflet", "jsonlite", "magrittr", "RSQLite", "knitr", "stringr",
"lubridate", "rbenchmark")
install.packages(pkgs)