Sed directory not found when running R with -e flag - r

When I try to run the following command:
R --slave --no-save --no-restore -e "print('foo')"
I get:
/usr/local/bin/R: line 193: /usr/local/Library/ENV/4.3/sed: No such file or directory
ERROR: option '-e' requires a non-empty argument
Apparently brew recently moved the ENV folder to a new path (see here). I know I can easily symlink the new sed dir to fix the issue but I wanted to know if there is a better workaround / fix (and eventually if this will be fixed in the R source code).

This happens because brew has changed it's paths in this commit so if you've run brew update in the last 4 days, this is what has caused the breakage.
Credit goes to blindjesse for this answer, which is to brew reinstall -s r.
I ran into some other issues when I tried this though. I didn't have X11 installed and I had a conflict with the tcl-tk which meant that it caused some other failures when it was compiling so:
I installed XQuartz from https://www.xquartz.org
Symlinked it to my homebrew folder ln -s /opt/X11/include/X11 /usr/local/include/X11 (note that your homebrew directory may be different)
brew install homebrew/dupes/tcl-tk
brew link --overwrite --force tcl-tk; brew unlink tcl-tk
brew reinstall -s r
And then it worked for me. I think once the r bottle is upgraded this issue should disappear but for the moment this is what I had to do.

Upgraded to Sierra, tried the commands above and also the directions here: https://github.com/Homebrew/homebrew-science/issues/4338. After I also reinstalled the R kernel following the instructions here: https://github.com/IRkernel/IRkernel, things started working again. Oy vey.
To reinstall the R kernel, start R in the terminal and enter the following:
install.packages(c('repr', 'IRdisplay', 'crayon', 'pbdZMQ', 'devtools'))
devtools::install_github('IRkernel/IRkernel')
IRkernel::installspec() # to register the kernel in the current R installation

Rather than having sed's path hardcoded, a simple workaround is to edit the R script and to change line 193 with
SED=$(which sed)

Related

R, issue "unable to load shared object cairo.so" on Linux CentOS 7

I've been using R with ggplot2 and other packages on my Linux CentOS 7 for a long time.
Today, all of a sudden, it stopped working.
When I call the png() function in my script, it generates the following errrors:
Warning messages:
1: In png(heatmap_file) :
unable to load shared object '/usr/lib64/R/library/grDevices/libs//cairo.so':
/lib64/libcairo.so.2: undefined symbol: FT_Get_Var_Design_Coordinates
2: In png(heatmap_file) : failed to load cairo DLL
I tried to update the cairo package many times but nothing worked out so far.
What can I do?
Thanks!
Your version of cairo (/lib64/libcairo.so.2) depends on a function called FT_Get_Var_Design_Coordinates. This function should come from FreeType. However, your version of libfreetype.so seems to be older and does not have this symbol. So, either you explicitly installed an older version, or "something" comes with an older version of FreeType.
I would look for files called libfreetype.so and check if they have the necessary symbol
I'm on Debian testing and here I get (this means that my version of FreeType does have this symbol; you would get no output if the symbol is not available):
$ nm -s -D /usr/lib/x86_64-linux-gnu/libfreetype.so | grep FT_Get_Var_Design_Coordinates
000000000001d260 T FT_Get_Var_Design_Coordinates
For you, based on the path to libcairo.so, I would expect something like /lib64/libfreetype.so to be the path to check.
I found a solution and I am going to share it with the community.
I am working on a Dell Latitude 3540 laptop running Linux CentOS 7 operating system (centos-release-7-3.1611.el7.centos.x86_64).
I ran sudo yum -y update and I understood there was a duplication issue regarding the freetype package, which was installed twice, and some other packages that were having conflicts.
I then removed the old freetype package and the conflicting packages with this command:
rpm -e freetype-2.4.11-12.el7.i686 --nodeps
rpm -e conflicting-package-1 --nodeps
rpm -e conflicting-package-2 --nodeps
...
Then I updated all the packages I manually removed:
sudo yum -y update freetype
sudo yum -y conflicting-package-1 freetype
sudo yum -y conflicting-package-2 freetype
...
This method worked out for me; I hope it might be helpful to someone.

How to install wordcloud in python3.6?

I installed wordcloud via conda in Windows 64
conda install -c conda-forge word cloud
but that is python 3.4.
I want to install word cloud in python 3.6
but i did search the google.
but it is not effect. so please teach me....
Anaconda Python 3.6 version
For Windows
==== Installation of wordcloud package ====
download wordcloud‑1.3.2‑cp36‑cp36m‑win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud
Copy the file to your current working directory
Open command prompt from Tools
python -m pip install wordcloud-1.3.2-cp36-cp36m-win_amd64.whl
It should work now
For MAC
pip install wordcloud
There is a solution, you can download a third party package for Python 3. Following the below steps helped me solve the problem.
Wordcloud_successful_install
Download wordcloud‑1.3.2‑cp36‑cp36m‑win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud
Copy the file to your current working directory
Open command prompt from Tools
Python -m pip install wordcloud-1.3.2-cp36-cp36m-win_amd64.whl
This will work:
1. create virEnv: conda create -n yourenvname python=3.5 anaconda
2. source activate yourenvname
3. conda install -c conda-forge wordcloud
Install wordcloud from the following page:
https://pypi.org/project/wordcloud/
Note: command: pip install wordcloud
Note: run the above command in Anaconda cmd prompt
Pre-requisities for instaling wordcloud is to install Visual C++(I got this error to install. So, you may give a try).This requires almost 4GB space. Once installed, restart your machine and then try the 1st step. It should be successful this time.
Ok. I solved my issue using wheels. Here are the steps:
Download the .whl file compatible with your Python version and your windows distribution (32bit or 64bit) from here https://www.lfd.uci.edu/~gohlke/pythonlibs/#wordcloud
cd to the file path
Run this command python -m pip install

Installing R 3.0.2 in Ubuntu 16.04

I'm having trouble trying to install R 3.0.2 in Ubuntu 16.04. I tried adding the repositories of older versions of R but the package for R 3.0.2 cannot be found in apt-get. Has anyone tried installing an older version of R on a newer version of Ubuntu? May I know what the steps are?
I tried also specifying the version in the apt-get install command but it didn't find the right package.
I see the best option in your case is to compile R. If you have never done such a thing, follow this little script in terminal:
# install common R dependencies
sudo apt-get install gcc \
g++ \
gfortran \
bzip2 \
libbz2-dev \
xorg-dev \
liblzma-dev \
libreadline-dev \
libpcre++-dev \
libcurl-dev \
libpango1.0-dev
mkdir R_alternatives
cd R_alternatives
mkdir src
mkdir 3.0.2
cd src
wget https://cran.r-project.org/src/base/R-3/R-3.0.2.tar.gz
tar -xvf R-3.0.2.tar.gz
cd R-3.0.2
#In my opinion is better to compile in one folder (avoid uncompress tar.gz source again, if you get any errors)
mkdir BuildDir
cd BuildDir
# this step will take around 2 minutes
./../configure --with-readline=no --with-x=no --prefix=/home/'user'/R_alternatives/3.0.2
# These two will take longer!!
make
make install
# following the prefix in 'configure' your R libraries are going to be installed in /home/'user'/R_alternatives/3.0.2/lib64/R/library/
# Hence, each time you compile a new R version, it will have its own libraries (this avoid R packages versions problems)
# If you wish more than one library version for the same R version, you must create a new folder and then run
export R_LIBS=/'path_to_your_new_folder'
# If you plan to use this R version in RStudio, you have to edit ~/.bash_profile, therefore you must run:
vi ~/.bash_profile
#or, It is up to you!
gedit ~/.bash_profile
#Then you put this line in end of the file
PATH=/home/'user'/R_alternatives/3.0.2/bin:$PATH
export PATH
# OR...
RSTUDIO_WHICH_R=/home/'user'/R_alternatives/3.0.2/bin/R
export RSTUDIO_WHICH_R
#PS: You can also set the R_LIBS here, in the same way!
First off, see here for a similar & older question on SO.
Pre-compiled binaries of older R releases for various Ubuntu versions (mostly the LTS releases) are available as deb's from the following website:
https://cran.r-project.org/bin/linux/ubuntu/
Unfortunately, there doesn't seem to exist a R 3.0.2 deb package for xenial; only precise still has the R 3.0.2 package. You could try to install the precise package in xenial, but that may come with its own problem set.
Might be best to compile from source following Facottons advice.

error: with-readline=yes (default) and headers/lib are not available

I am trying to install RHadoop. I have used following instruction in a Virtual box Ubuntu 12.04 64 bit version.
$wget https://launchpad.net/ubuntu/quantal/+source/r-base/2.15.1-3ubuntu1/+files/r-base_2.15.1.orig.tar.gz
$ tar -zxvf r-base_2.15.1.orig.tar.gz
$ sudo apt-get install gfortran
$ cd R-2.15.1/
$ ./configure --with-x=no
When I run this command, I get the error mentioned above. Google also does not have any suggestions for this error although many talk about X11
Readline is a GNU package that you can find here; your first option consists in installing it before trying to build R again.
Alternatively, if you are sure you do not need R to be built with this library, you can simply set with-readline to "no":
./configure --with-x=no --with-readline=no
Setting readline to no is something I considered, but than think of this, what if you need it. I am not even sure what it is 100%, but I assume it lets R read from user input of some sort.
Anyways, I just resolved this error by installing readline-devel on centos via yum. On debian I think it's something like libreadline-dev. The point is that you need development files which include .h files necessary for R.
This solution works for me:
error: --with-x=yes (default) and X11 headers/libs are not available
Solution:
Code:
$ sudo apt-get install xorg-dev
For Centos 7, to install X11
# yum install xorg-x11-server-devel libX11-devel libXt-devel
Now ./configure

Rscript on ubuntu

Where can I install Rscript from? I need to run an R script from a php file using exec. However I need to install Rscript first.
The main package for R is called r-base. For the scripting and command-line front-end see littler (or r-cran-littler in xenial (16.04LTS) and beyond):
sudo apt-get install littler
Search the ubuntu repositories. Have you checked the littler package?
The answers posted so far are generally useful, but they don't directly answer the question. I recently had the same question and discovered there is no rscript binary for Ubuntu. The r binary itself is used to execute scripts in batch mode as opposed to the separate rscript binary that I was using in OS X.
It appears you may be able to get an rscript binary from other sources (see http://craig-russell.co.uk/2012/05/08/install-r-on-ubuntu.html#.UwKWzkJdW2Q for example), but I'm not sure why you would need that when simple running "r script.r" from the command line works just fine.
I tried running Rscript in a fresh ubuntu installation (16.04.2 LTS) and got:
The program 'Rscript' is currently not installed. You can install it by typing:
sudo apt install r-base-core
so, naturally, i ran sudo apt install r-base-core.
installation took a couple of minutes.
Later, i needed to install an R package, and realized i needed an R shell for that. running r returned:
The program 'r' is currently not installed. You can install it by typing:
sudo apt install r-cran-littler
Again, i followed, this time it was quite faster.
I don't know if these are the correct steps to take (or why they would be wrong), but it's what the system led me to do.

Resources