I've installed R and RStudio via brew. For a project I need a function from the R library geoR which in turn is dependent on tcl-tk. I installed this as well via brew: brew install tcl-tk. However, trying to install geoR still leads to the error below - which I don't get.
Reinstalling R/RStudio didn't help. Nor did re-starting my Mac. Oh, and trying to install geoR from the downloaded binary from CRAN doesn't help either...And lastly, trying to install the tcl-tk package from the R website doesn't solve this either.
I also posted this on the GitHub of brew - but perhaps others visit the realms of StackOverflow.
My brew status
brew config
HOMEBREW_VERSION: 1.5.2
ORIGIN: https://github.com/Homebrew/brew
HEAD: 60a30e966b7cece5bd4823dae3fb981ab85106ea
Last commit: 11 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 8c1c4f86a269cb23d9d92008abf1a37eabb297b6
Core tap last commit: 2 hours ago
HOMEBREW_PREFIX: /usr/local
CPU: quad-core 64-bit skylake
Homebrew Ruby: 2.3.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 9.0 build 900
Git: 2.16.1 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
Perl: /usr/bin/perl
Python: /usr/local/opt/python/libexec/bin/python => /usr/local/Cellar/python/2.7.14_2/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Java: 9.0.1
macOS: 10.13.3-x86_64
Xcode: N/A
CLT: 9.2.0.0.1.1510905681
X11: 2.7.11 => /opt/X11
ERROR
* installing *source* package ‘geoR’ ...
** package ‘geoR’ successfully unpacked and MD5 sums checked
** libs
clang -I/usr/local/Cellar/r/3.4.3_1/lib/R/include -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include -fPIC -g -O2 -c geoR.c -o geoR.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/3.4.3_1/lib/R/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/lib -o geoR.so geoR.o -L/usr/local/Cellar/r/3.4.3_1/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
installing to /usr/local/lib/R/3.4/site-library/geoR/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Warning: S3 methods ‘as.character.tclObj’, ‘as.character.tclVar’, ‘as.double.tclObj’, ‘as.integer.tclObj’, ‘as.logical.tclObj’, ‘as.raw.tclObj’, ‘print.tclObj’, ‘[[.tclArray’, ‘[[<-.tclArray’, ‘$.tclArray’, ‘$<-.tclArray’, ‘names.tclArray’, ‘names<-.tclArray’, ‘length.tclArray’, ‘length<-.tclArray’, ‘tclObj.tclVar’, ‘tclObj<-.tclVar’, ‘tclvalue.default’, ‘tclvalue.tclObj’, ‘tclvalue.tclVar’, ‘tclvalue<-.default’, ‘tclvalue<-.tclVar’, ‘close.tkProgressBar’ were declared in NAMESPACE but not found
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: fun(libname, pkgname)
error: Tcl/Tk support is not available on this system
ERROR: lazy loading failed for package ‘geoR’
* removing ‘/usr/local/lib/R/3.4/site-library/geoR’
* restoring previous ‘/usr/local/lib/R/3.4/site-library/geoR’
The downloaded source packages are in
‘/private/var/folders/kh/0s66cjl5487fg_fhwgxqd2340000gn/T/RtmpooD5vJ/downloaded_packages’
Warning message:
In install.packages("geoR") :
installation of package ‘geoR’ had non-zero exit status
Well, after a lot of googling, and analyses of what I read, I deduced a solution.
Here I add some background on why I needed a solution and the Step-by-Step procedure I took. Note it certainly is not a final solution/procedure and maybe some steps are redundant - I'll let that to others.
Background
Sometimes data is very skewed and contains a lot of 'zeros' (or very small numbers approaching 'zero'). Before analyses such data need normalisation to meet the assumptions of a statistical test (you can find more on transformation and normalisation here). Usually people log-transform (e.g. natural log, or log2), the disadvantage is that you loose the 'zeros'.
In my case that is an issue, because the measurements made were properly done (no technical issues), so 'zero' really represents 'zero'. In other words: I don't want to loose them. Some years back a colleague of mine pointed me to 'Box-Cox' transformation (you can find more on that here), and this method is available in
Rvia thegeoRpackage.The thing is: I use
brewto installRand many other packages/libraries lacking on macOS, e.g.wget. For reasons I still don't get - but I also realize it's beyond my coding capabilities -brewdoes not normally installRwith thetcl-tkpackage. And let that be the critical part you need forgeoRand by extension the functionboxccoxfitto work. After some googling I got some hints that led me to a (on the face of it) permanent solution; the discussion on thebrewwebsite were critical.Step-by-Step
I made sure I have tcl-tk installed via
brew.brew install tcl-tktcl-tkwas in my path:echo 'export PATH="/usr/local/opt/tcl-tk/bin:$PATH"' >> ~/.bash_profile.wishalso confirmed this.I also made sure I had installed Command Line Tools properly - there were some updates to High Sierra in the last week, and others had reported issues with that, so I feared it might had to re-installed. I didn't have to, but here's how I checked that. The command
brew configshows:The bold printed line suggests that
Command Line Toolsshould be installed.I than double checked if the path was really set, using the command
xcode-select -p, which shows:Also
gccis properly set. I checked this usinggcc --version, which shows:Now that I had confirmed the basics are present, I proceeded by re-installing
Xquartz,RandRStudio. To make sure I get theRwithtcl-tkI used the R version of @srfore. These are the subsequent commands.brew cask reinstall xquartz, re-installXquartz. Optional, if already installed.brew reinstall -s sethrfore/homebrew-r-srf/r, installed a edited version ofR.brew cask reinstall rstudio, re-installRstudio. Optional, if already installed.All seemed well, I double checked with
brew doctor.Of course, for me, this all started with the need to use the function
boxcoxfitfrom theRpackagegeoRwhich is dependent ontcl-tk. So, now it was showtime and I started R:And loading `geoR` was not an issue: