Rscript on ubuntu - r

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.

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.

Installing Sqlite3 on Ubuntu 14.04 for Python3.6

I have a virtual environment set up with python 3.6. I'm trying to install sqlite3 (I built python from source) and am having trouble doing so. (I need sqlite3 for tensorboard)
After some digging I found an approach:
sudo apt-get install libsqlite3-dev
Now in the downloaded python source rebuild and install python with the following command:
./configure --enable-loadable-sqlite-extensions && make && sudo make install
The issue is I cannot run the first command. Running the first command gives me the error "download failed Oracle JDK 6 is NOT installed." Therefore I downloaded the libsqlite3-dev file.
My question is, where should this be placed before I can run step 2.
I've looked around for a solution for a few hours now ans seem to be at a loss. Any help would be really appreciated with either solving this approach or proposing another approach.
Use Anaconda
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
conda create -n envsq python=3.7
source activate envsq
python
And you can import sqlite3 with no issues.

MXNet R package on an Amazon Linux Deep Learning EC2 instance

I'm attempting to setup an Amazon Linux EC2 instance with MXNet and R (and the MXNet r package available as well). Unfortunately this has been a lot harder than I expected.
I've attempted to follow the instructions from MXNet using Amazon's deep learning AMI with CUDA 8.0 on a p2.xlarge (https://mxnet.incubator.apache.org/get_started/install.html)
However I get the same error when attempting to compile the mxnet r package from this SO post:
Issues installing mxnet GPU R package for Amazon deep learning AMI
The solution discussed in that post are somewhat beyond my abilities to fully test/debug. i.e. I'm not particularly familiar with linux environment variables and such to modify. I've also reviewed some issues raised on the apache-incubator github for MXnet and those were pretty unhelpful as well.
So my questions are,
Is anyone aware of any available AMI's which come pre-packaged with R and MXNet? The ones I see seem to only include python.
Have a working set of instructions (or a script) to run on an Amazon Linux EC2 instance to install the required dependencies (assuming Im using some type of deep learning AMI that comes with CUDA 8.0 at least) to install the MXnet R package?
Right so I was the guy on the other post and I DID eventually get it working. Took 50+ hours and I'm not 100% sure where the issue was because...linux.
sudo yum install R
sudo yum install libxml2-devel
sudo yum install cairo-devel
sudo yum install giflib-devel
sudo yum install libXt-devel
sudo R
install.packages("devtools")
library(devtools)
install_github("igraph/rigraph")
install.packages(c(“DiagrammeR”, “roxygen2”, “rgexf”, “influenceR”, “Cairo”, “imager”))
cd
cd /src/mxnet
cp make/config.mk .
echo "USE_BLAS=openblas" >>config.mk
echo "ADD_CFLAGS += -I/usr/include/openblas" >>config.mk
echo "ADD_LDFLAGS += /usr/local/lib" >>config.mk
echo "USE_CUDA=1" >>config.mk
echo "USE_CUDA_PATH=/usr/local/cuda-9.0/lib64" >>config.mk
echo "USE_CUDNN=1" >>config.mk
*add another LD flag for /usr/local/lib
cd /etc/ld.so.conf.d/
sudo nano cuda.conf
Insert  /usr/local/cuda-9.0/lib64
cd
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
sudo ldconfig
cd R-package
Rscript -e "install.packages('devtools', repo = 'https://cran.rstudio.com')"
Rscript -e "library(devtools); library(methods);options(repos=c(CRAN='https://cran.rstudio.com'));install_deps(dependencies = TRUE)"
cd ..
sudo make rpkg
THEN you gotta make sure R/Rstudio can actually find those libraries:
cd /etc/rstudio
sudo nano rserver.conf
You can add elements to the default LD_LIBRARY_PATH for R sessions (as determined by the R ldpaths script) by adding an rsession-ld-library-path entry to the server config file. This might be useful for ensuring that packages can locate external library dependencies that aren't installed in the system standard library paths. For example:
rsession-ld-library-path=/opt/local/lib:/usr/local/cuda/lib64

Installing R packages on Amazon Linux EC2 instance

I am learning to use RSelenium in an EC2 instance, and I found this handy guide on doing so - https://rpubs.com/grahamplace/rselenium-ec2 - however the guide focuses on an Ubuntu instance and I am using an Amazon Linux Instance. In order to install RSelenium, the guide says I must externally (outside of R but ssh'd into my EC2 instance) install the packages xml (XML i think, case sensitive) and RCurl. The guide's relevant lines of code are:
sudo apt-get install r-cran-xml
sudo apt-get install r-cran-RCurl
however, since I'm in an Amazon Linux instance, I tried:
sudo yum install r-cran-xml
sudo yum install r-cran-RCurl
for which I get the following error:
No package r-cran-RCurl available.
Error: Nothing to do
Note: I was successful in installing R on my machine (my instance), and I am able to simply type R to launch R in the EC2 instance.
Note2: install.packages('XML') and install.packages('RCurl') with R launched do not work either.
Any help appreciated with this, thanks!
the amazon linux R package has a different name:
sudo yum install -y R
then you tried (in R) install.packages(c('XML','RCurl')), but the installation failed.
as you discovered and describe in the comment below, you needed to install an additional amazon linux package, libxml2-devel, in order to install.packages('XML') successfully.
this is what I get when I run sudo yum install -y R
No package R available.
Error: Nothing to do
R is available in Amazon Linux Extra topic "R3.4"
To use, run
sudo amazon-linux-extras install R3.4
Learn more at
https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras

Sed directory not found when running R with -e flag

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)

Resources