dekkera:pkgconfig peter$ brew info libxml2 R
libxml2: stable 2.9.7 (bottled), HEAD [keg-only]
GNOME XML library
http://xmlsoft.org/usr/local/Cellar/libxml2/2.9.7 (281 files, 10.4MB)
Poured from bottle on 2018-02-16 at 22:42:54
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libxml2.rb==> Options
--HEAD
Install HEAD version
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/libxml2/lib
CPPFLAGS: -I/usr/local/opt/libxml2/include
For pkg-config to find this software you may need to set:
PKG_CONFIG_PATH: /usr/local/opt/libxml2/lib/pkgconfig

Re: Problem installing libxml2 under Homebrew

You probably have a malconfigured homebrew installation of R. On MacOS
it is recommended to use the CRAN version of R
https://cran.r-project.org/bin/macosx/. The homebrew version depends
on gcc compilers and does not support cran binary packages.

If you really want to use the homebrew R try ruling out the following problems:

- Check for conflicting compilers in your path (gcc, ccache, clang4).
Unless you have good reasons not to, you should use the native xcode
compilers to build R packages.
- Comment out custom compilers/flags that you may have in your
~/.R/Makevars file.