how to install RODBC on macOS Sierra 10.12.4 - r

In R 3.4.0,
install.packages('RODBC', type='source')
fails on macOS 10.12.4. I also downloaded RODBC_1.3-15.tar.gz from CRAN and tried,
R CMD INSTALL RODBC_1.3-15.tar.gz
In both cases, I got "ODBC headers sql.h and sqlext.h not found". A discussion of this in Installation of RODBC/ROracle packages on OS X Mavericks says the following:
To fix this, you need to download the latest version of iODBC (www.iodbc.org), and then unzip the file and set your header and library search paths to the location where you put the unzipped package. If you don't know how to set your search paths, you could just put the header files (sql.h and sqlext.h) in the /usr/include directory, and the libiodbc.a file in the /usr/lib directory.
I downloaded iodbc-42.5.tar.gz and untarred it into a directory next to RODBC, untarred from RODBC_1.3-15.tar.gz. Sadly, I can't find how to set header and library search paths, and when I try to put the header files in /usr/include, the system won't let me.
iodbc-42.5/iodbc/README.MACOSX says,
You first need to install the latest Mac OS X Developer Packages, which can be found at http://developer.apple.com/tools
I think I've done that, but I don't know how to check it. [In fact, I think I've done it multiple times: The message ODBC headers sql.h and sqlext.h not found, disappeared for a while from the still-negative response to install.packages('RODBC', type='source'), only to reappear later after I successfully installed port and ran sudo port install gcc6. Then I got ODBC headers sql.h and sqlext.h not found again.]
iodbc-42.5/iodbc/README.MACOSX continues,
Then, you can open the Xcode Project Builder files under mac/iODBCinst, mac/iODBC, mac/iODBCtest and mac/iODBCtestw.
I don't know how find any of these. It further continues,
or execute the following commands from a terminal session to build all the frameworks and demo applications:
$ cd mac
$ make
I did $ cd mac and got -bash: cd: mac: No such file or directory. Evidently, I need to substitute something for mac here, but I don't know what. ???
Thanks.

I solved the problem with:
ODBC_INCLUDE=/path/to/libiodbc-srcs/include R CMD INSTALL RODBC
where "/path/to/libiodbc-srcs/include" is the path to the "include" folder containing the missing files, "sql.h" and "sqlext.h". In my case it was something like '~/Documents/Rstuff/iodbc-42.5/iodbc/include', which I checked with the following in R:
dir('~/Documents/current/Rstuff/iodbc-42.5/iodbc/include')
Then the following worked for me:
ODBC_INCLUDE=~/Documents/current/Rstuff/iodbc-42.5/iodbc/include R CMD INSTALL RODBC
This is described in p. 19 of https://cran.r-project.org/web/packages/RODBC/vignettes/RODBC.pdf, except that contains a stray quote (<'>), which threw me off the first few times I read it, because was not familiar with that syntax.
On R-Sig-Mac, Marc Schwartz offered two suggestions: First, Installation of RODBC on OS X Yosemite, which may work with "brew"; I didn't try that, because I got the above to work first.
Second:
install.packages("RODBC", type = "source",
configure.args = "--with-odbc-include=/path/to/libiodbc-srcs/include/")
This should work also with the path substitution mentioned above.
I hope this helps someone else.

Related

Can I change the location of Homebrew FFTW install? R can't seem to read FFTW3.h file located in Cellar folder

I'm trying to install wholebrain by Daniel Fürth, following the instructions on the macosX install page (available here). I am running MacOS Big Sur 11.5.2, R 4.1.2, and RStudio 2021.09.1.
Unfortunately, the program is not straight-forward to install and requires significant developer tools to work correctly. I'm not a programmer and have almost no experience with coding, so I've been mucking through the instructions for two days now trying to get the install to work correctly and I'm firmly stuck on the final step.
In RS, when I run, devtools::install_github("tractatus/wholebrain", INSTALL_opts=c("--no-multiarch")) I get the following error message:
/bin/sh: pkg-config: command not found filter.cpp:9:10: fatal error: 'fftw3.h' file not found #include "fftw3.h" ^~~~~~~~~ 1 error generated. make: *** [filter.o] Error 1 ERROR: compilation failed for package ‘wholebrain’
I have been trying to figure out what this means for quite awhile now and I think I've narrowed it down to R is not reading the location of the fftw header file from where it was installed by Homebrew. (I could be totally wrong, again- not a programmer)
From what I understand, Homebrew always installs under opt/homebrew/cellar. And, in fact, in there is the compiled fftw program with the needed "fftw3.h" file. But for some reason, RStudio is not able to find and read the file in that location.
From random googling and reading of other posted issues, I think that RStudio may expect the file to be under usr/local/include. Can I just copy and paste the header file into that folder? Or will I be screwing something up if I do that? I am totally intimidated by fftw's description of manual compilation so I don't really want to attempt that. Is there a way to change where R is looking for that header file? I already set my wd to "/" so shouldn't R be able to access any folder on my computer?
I want to post an answer here for anyone who comes after me with the same issue. It came down to RStudio not recognizing the programs Homebrew had installed because it wasn't reading the file location where Homebrew saves them. Homebrew always installs programs in /opt/homebrew/... Here is what I had to do:
In RStudio, open your Renviron file using this command: usethis::edit_r_environ()
In the file that opens (which for me was totally blank), type: PATH=/opt/homebrew/bin:${PATH}, or whatever your particular path you want prepended to the Renviron path is.
Quit RStudio and, when prompted, save. Re-open RStudio and run Sys.getenv("PATH") to check. Your new path (in the example above, '/opt/homebrew/bin') should now be prepended to the list of paths that RStudio will use when looking for programs/files. For me this now looks like /opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Applications/RStudio.app/Contents/MacOS/postback
Finally, I want to say thank you very much to Mark Setchell who really helped point me in the correct direction!

jpeg R package instalation does not find jpeglib.h in non standard location

I'm trying to install jpeg package in R in a Linux server (in which I don't have sudo access) and jpeg installation does not find jpeglib.h I installed locally. How do I tell R where to look for it when configure.args='--with-libjpeg-include=/path failed?
Sever OS version is CentOS Linux 7 (Core)
In R I ran:
>install.packages('jpeg', lib="/shared/mybossusr/R3.5.0/lib", repos="https://mirrors.nic.cz/R/", destdir="/shared/mybossusr/usr/tmp")
And I got this error:
rjcommon.h:11:21: fatal error: jpeglib.h: No such file or directory
#include
So I installed jpeg-turbo
wget https://downloads.sourceforge.net/libjpeg-turbo/libjpeg-turbo-2.0.2.tar.gz
mkdir libjpeg-turbo-2
cd libjpeg-turbo-2
cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX:PATH=/shared/mybossusr/bin/libjpeg-turbo-2 /shared/mybossusr/download/libjpeg-turbo-2.0.2
make
make install
I checked and jpeglib.h is at /shared/mybossusr/bin/libjpeg-turbo-2/include
I added this at the end of my ~/.bashrc :
export CFLAGS="-I/usr/include -I=/shared/mybossusr/bin/libjpeg-turbo-2"
I logged out and in, and I got the same error when trying to install jpeg in R.
I also added the location of the library to my path at ~/.barsh:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/shared/mybossusr/bin/libjpeg-turbo-2/include
export PATH=$PATH:/shared/mybossusr/bin/libjpeg-turbo-2/include
just in case, because I don't fully understand when a software looks where. Did source ~/.bashrc, logged out and in, but nothing changed.
So, I tried afterwards in R some arguments I came up with:
install.packages('jpeg', lib="/shared/mybossusr/R3.5.0/lib", repos="https://mirrors.nic.cz/R/", destdir="/shared/mybossusr/R3.5.0/tmp", configure.args='--with-libjpeg-include=/shared/mybossuser/bin/jpeg/include')
and:
install.packages('jpeg', lib="/shared/mybossusr/R3.5.0/lib", repos="https://mirrors.nic.cz/R/", destdir="/shared/mybossusr/R3.5.0/tmp", configure.args='--with-libjpeg=/shared/mybossuser/bin/jpeg')
or:
install.packages('jpeg', lib="/shared/mybossusr/R3.5.0/lib", repos="https://mirrors.nic.cz/R/", destdir="/shared/mybossusr/R3.5.0/tmp", configure.args='--with-libjpeg-lib=/shared/mybossuser/bin/jpeg/include')
to try to tell R where libjpeg was installed, but nothing worked.
Is there any configure.args that will do the trick? So far with other packages it was quite straight forward to use a --with-package_name-lib, but I'm clueless with this one...
Thanks in advance!
Try installing the libjpeg-turbo-devel package. That's what did it for me on RHEL 7. According to this page, on CentOS 7 the package name is the same.
For me this is what did the trick:
Install jpeg-turbo in a non-standard location, say $HOME/local, from:
https://github.com/libjpeg-turbo/libjpeg-turbo/releases
cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX=$HOME/local
make
make install
Then point these globals to the install location in your .bashrc:
export LIBRARY_PATH=$HOME/local/lib64:$HOME/local/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=$HOME/local/lib64:$HOME/local/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$HOME/local/include:$C_INCLUDE_PATH
Then try the R package again

Passing argument to R with Command Prompt [duplicate]

I'm exploring package building on Windows 7 but have been running into trouble after reaching the Command Prompt stage. The following thread appears to be on the same topic that I'm having trouble with, but the question remains unresolved:
Cannot install R package in Windows 7
The problem: whenever I try an R CMD command in Command Prompt (e.g. I've tried R CMD install pkgName, R cmd install pkgName, Rcmd install pkgName, where pkgName is a place-holder for an actual package that has been R CMD checked on OS X and also posted on CRAN, where I have the unzipped source in the current working directory), I get the following error message:
'R' is not recognized as an internal or external command,
operable program or batch file.
(If I try the Rcmd install pkgName command, then the error starts out as 'Rcmd' is not ....) Note that even if I type in just R in Command Prompt and hit enter, I get the same error, so I'm not even able to bring up R here, though it opens perfectly fine in its stand-alone interface.
I have examined the following guides without success in identifying the trouble:
Karl W Broman's website
Rob J Hyndman's website
Steven Mosher's blog
The most immediate thing that came to mind was that the path variables in Windows were not set right, but this also has not (yet) led to the answer. For example, I have triple-checked the paths to ensure they are correct, including for the R version number, that x64 in the path name is accurate, etc.
I realize this is a complex issue to remotely diagnose, but any advice and suggestions on resolving this trouble is appreciated. For reference, below are the steps I have taken already to try to resolve this issue:
Uninstall R and Rtools
Install the latest version of R (2.15.0)
Install Rtools215 to match R version 2.15.0
Originally I let Rtools specify the path variables (turning that option on during installation). No success after this method.
I updated the path variables on my computer, where the below paths were used:
C:\Rtools\bin; C:\Program Files\R\R-2.15.0\bin\x64;
I've also tried the R CMD (and Rcmd) commands with the following paths included (note that these paths don't lead to anything on my computer, so I tried doing R CMD / Rcmd with and without them specified):
C:\Rtools\perl\bin; C:\Rtools\MinGW\bin;
Tried adding/removing the following path, which goes to the only other folder visible within the Rtools folder:
C:\Rtools\gcc-4.6.3;
Tried multiple variations of the R CMD commands, as noted earlier.
I tried this all a few months ago when I had R version 2.14.1 and Rtools214 installed, and I had the exact same trouble.
Note: I already had Cygwin installed prior to R and Rtools, and I have not installed MikTeX (yet).
Have you closed the command prompt and opened a new one after adjusting the PATH?
Enter the command PATH on the command line and ensure that you are properly updating your path
Try navigating to the directory where R.exe is saved and running it locally -- cd C:\Program...\bin\x64, R.exe.
Ensure that you're running on Windows' Command Prompt and not Cygwin's terminal
If you actually have a space after the semi-colon in your PATH, you'll need to remove that: /bin;C:/Program.... Try combining that with Joshua's solution.
I attach my whole solution here:
Install Rtools which is compatible with my R version
Add PATH: C:\Program Files\R\R-2.15.1\bin\x64;C:\Rtools\bin;C:\Rtools\gcc-4.6.3\bin
In cmd, enter: R CMD INSTALL packagename
Click "enter", done.
I had a lot of trouble getting this to work, and finally found the golden nugget on r-project (R doesn't like spaces in paths) so here's how I finally did all this:
I installed R to "c:\programs" instead of "c:\program files...". My final path to RSCRIPT.exe is "C:\Programs\R\R-2.15.2\bin\Rscript.exe"
I added that directory to my PATH, but that doesn't seem to help
RStudio is also installed under c:\Programs (e.g. c:\Programs\RStudio), but RTools is installed under the "c:\" root directory (e.g. c:\RTools).
I downloaded all the packages to "c:\downloads\r"
I opened a command prompt in "c:\downloads\r" and ran the R CMD install from this downloads directory, specifying the path to R
e.g. "C:\Programs\R\R-2.15.2\bin\x64\R CMD INSTALL colorspace_1.2-0.zip"
It appears that the CMD processor is Case Sensitive. You have to use INSTALL vs. install
Simple solution, use quotes:
c:> "C:\Program Files\WinZip\wzunzip.exe"
if you run this, you don't need to worry about the space in Program Files.
Hope this help.
I encountered a similar problem while trying to use SparkR from Windows Power Shell. Each time I would do ".\sparkR.cmd" (I was inside the folder containing this file), it would throw an error message like,
cmd is not recognized as an internal and external
command...blah...blah...blah.
I solved the problem by adding "C:\Windows\System32" to my PATH.
I restarted my system and then repeated the process and this time, I saw a new error,
R is not recognized as an internal and external
command...blah...blah...blah.
I tried all sorts of approaches, including the ones mentioned above. NOTHING WORKED, I was probably wasn't efficient enough to make it work.
Then I came across this place at code.google. I simply copied the R.bat onto a notepad, named it as R.bat. Kept it inside the folder where sparkR.cmd was located. For me it was,
C:\Apache\spark-1.5.1-bin-hadoop2.6\bin\
The I placed it on my PATH as :
C:\Apache\spark-1.5.1-bin-hadoop2.6\bin\R.bat
Restarted my laptop, opened my Power Shell as an administrator and typed :
.\R.bat help
It worked fine. Then I typed,
.\sparkR.cmd
and there it was.
It worked.
I hope it helps to people new to R. Thank you G. Grothendieck.
In the .bat file add a line of code specifying the path of the folder where R is installed and then give the path of the script as follows -
#ECHO OFF
PATH C:\Program Files\R\R-3.5.1\bin
R CMD BATCH D:\project_abc\helloworld.R
Following this, run the .bat file and you will see the code in the script will run smoothly.
In my case the issue was solved by using Edit instead of New while selecting PATH in the window below:
enter image description here
After selecting Edit I added the directory below:
C:\Program Files\R\R-4.0.2\bin\x64
This solved the issue in my case.

Emacs on Mac, R, and OS X el Capitan

I use Emacs and/or Aquamacs on a Mac system to edit the R, latex, and html code. After upgrading OS X to el Capitan, R stopped working (searching for program: no such file or directory, R). I was wondering if anybody encountered the same problem and found the solution.
This is what I did and it solved the problem.
re-install R (the latest version at the time of writing this post is 3.2.4)
include (setq exec-path (cons "/usr/local/bin" exec-path)) in the .emacs.
/usr/local/bin is where the command line R is soft linked.
Of course if the R command is not found in /usr/local/bin but somewhere else, you should change the path in step 2.
I had to re-install R and all the packages after upgrading. To be able to do this step easily, save your installed packages in a file before upgrading to El Capitan. The packages have not actually been removed, they reside in
/Library/Frameworks/R.Framework/Versions/3.2/Resources/library (3.2 = version), so you can still find them, but some may be in your user library.
To save your list of packages:
my.packages = library()[[2]]
write.table(my.packages,file="my.packages.txt", row.names=F, col.names = T)
Then upgrade, re-install from R-3.2.2.pkg (or latest), then read the text file in my.packages and use install.packages(my.packages, repos='http://cran.us.r-project.org') and you should be good to go.
Regarding R under "El Capitan", you do not necessarily have to re-install it. You can find out what happened by listing the directory
ls -l /Library/SystemMigration/History/Migration-<UUID>/QuarantineRoot/usr/bin
(where <uuid> looks like 38CF2251-9593-48E9-BAA4-4880AA47E908). This is where the OS upgrade put the links that used to live in /usr/bin. Just create the same symlinks to R and Rscript as root:
cd /usr/local/bin
ln -s /Library/Frameworks/R.framework/Resources/bin/R R
ln -s /Library/Frameworks/R.framework/Resources/bin/Rscript Rscript
This assumes, of course, that /usr/local/bin is in your PATH.
New installations of R should be aware of the changes in El Capitan, cf. this R bug report.
Here is another solution: replace emacs with ``modified emacs''. It solves all the problems with Auctex (latex-preview-pane-mode) and R. It is also consistent with OS 10.11.
You can download it from: http://vgoulet.act.ulaval.ca/en/emacs/mac/
I had the same problem getting R to run on El Capitan. The problem is now solved. What follows is exacly what I tried. You might find some of the steps irrelevant but I've included them for the sake of completeness.
Tried reinstalling it via homebrew (mentioined above) and got an incompatible message concerning el capitan.
Loaded 'modified emacs' (mentioned above).
Visited the following link:
http://ftp.heanet.ie/mirrors/cran.r-project.org/bin/macosx/
then downloaded and installed:
(i) R-3.2.2.pkg
and ran the checksum command in Terminal as directed by the instructions.
(ii) XQuartz
4. Then in terminal, typed R
and it worked.
For the course I'm doing, other packages or libraries were needed. To load the package 'geonames, in Terminal type:
install.packages(c("geonames"))
A message will appear asking to select a CRAN mirror. Also another window will open with a list of mirrors, click one and OK.
Similarly, the package 'UsingR' was loaded by:
install.packages(c("UsingR"))
__end
I think the problem is that usr/bin is no longer writeable. And that's where programs like R and Rscript lived. On my system, it looks like usr/bin was moved to something like:
/Library/SystemMigration/History/Migration-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/QuarantineRoot/usr/bin
I suppose you can add that quarantined folder to your path as on my system everything seems to be working fine if executed from there.
I had the same problem. I'm not sure what's changed in El Capitan but adding the path to the R binary (/usr/local/bin on my system) to the exec-path in my .emacs file fixed the issue for me.

Problem loading rJava

Yesterday I removed R2.11 from my system (Win7, 64bit), since I´m working on R2.13.
Since then i get an error message:
> require(rJava)
Lade nötiges Paket: rJava
Error : .onLoad in loadNamespace() fehlgechlagen, Details:
Aufruf: rJava
Fehler: inDL(x, as.logical(local), as.logical(now), ...)
I tried specifying PATH, since I found on the internet that it might have something to do with jvm.dll:
c:\Rtools\bin;
c:\Rtools\perl\bin;
c:\Rtools\MinGW\bin;
c:\Rtools\MinGW64\bin;
C:\Windows\system32;
%R_HOME%\bin;
C:\Program Files\R\R-2.13.0\bin;
C:\Program Files\Java\jre6\bin\server
However I could not solve the problem...
I also can´t run R from the win command line (just type "R"?)
Any suggestions?
Here is some quick advice on how to get up and running with R + rJava on Windows 7 64bit. There are several possibilities, but most have fatal flaws. Here is what worked for me:
Add jvm.dll to your PATH
rJava, the R<->Java bridge, will need jvm.dll, but R will have trouble finding that DLL. It resides in a folder like
C:\Program Files\Java\jdk1.6.0_25\jre\bin\server
or
C:\Program Files\Java\jre6\jre\bin\client
Wherever yours is, add that directory to your windows PATH variable. (Windows -> "Path" -> "Edit environment variables to for your account" -> PATH -> edit the value.)
You may already have Java on your PATH. If so you should find the client/server directory in the same Java "home" dir as the one already on your PATH.
To be safe, make sure your architectures match.If you have Java in Program Files, it is 64-bit, so you ought to run R64. If you have Java in Program Files (x86), that's 32-bit, so you use plain 32-bit R.
Re-launch R from the Windows Menu
If R is running, quit.
From the Start Menu , Start R / RGUI, RStudio. This is very important, to make R pick up your PATH changes.
Install rJava 0.9.2.
Earlier versions do not work! Mirrors are not up-to-date, so go to the source at www.rforge.net: http://www.rforge.net/rJava/files/. Note the advice there
“Please use
`install.packages('rJava',,'http://www.rforge.net/')`
to install.”
That is almost correct. This actually works:
install.packages('rJava', .libPaths()[1], 'http://www.rforge.net/')
Watch the punctuation! The mysterious “.libPaths()[1],” just tells R to install the package in the primary library directory. For some reason, leaving the value blank doesn’t work, even though it should default.
I finally solved the problem:
It seems that rJava searches for jvm.dll in ~\Java\jre6\bin\client.
However this folder didn´t exist on my system (jvm.dll was in ~\bin\server).
So I just made a copy of jvm.dll in a folder ~\bin\client\ and added this to the path.
Now everything works fine!
My problem was solved by
install.packages("SqlRender",INSTALL_opts="--no-multiarch")
It was a package that depends on rJava and all advices were telling me to fix Java installation. But the solution was to use install option that simply forgets about i386 architecture. (also works with drat library and packages not from CRAN)
This may be due to a conflict between RStudio and Java versions. If you have installed 64 bit java and RStudio is running in 32 bit mode, you may experience problems like this. As a solution, you can change the 32-64 bit selection in the Tools-> Global Options-> General section in RStudio.
You can find detailed information here.
In my case installing proper version of Java solved my problem.
I installed 64x bit java, cause I use 64x bit R version.
I solved it by following these steps
setting my environment Sys.setenv(JAVA_HOME='C:\\Program Files (x86)\\Java\\jre6')
Manually installing rJava package from install package (even this should work:
install.packages('rJava', .libPaths()[1], 'http://www.rforge.net/'))
library(rJava)
I solved this problem as follows. I've been trying for 2 days.
Windows 7 users do not write ... \ bin \ x64 in environment variables.
Instead, define the path as follows.
JAVA_HOME "C: \ Program Files \ Java \ jre1.8.0_251"
R_HOME C: \ Program Files \ R \ R-3.5.3
In RStudio type .LibPaths()
This will give you an path in you windows system where your library’s are located
Go there and delete rJava. If it is being used by applications of Java, kill all Java programs in the Task Manager.
Go to computer and properties, click on change environment variables
Edit JAVA_HOME and all Java related paths to the path where your newest installation of Java is located and save.

Resources