R

From Gentoo Wiki
Jump to:navigation Jump to:search

R is a programming language primarily for statistics and numerical analysis.

Installation

USE flags

USE flags for dev-lang/R Language and environment for statistical computing and graphics

+libdeflate Use app-arch/libdeflate rather than sys-libs/zlib for lazy-loaded R objects.
X Add support for X11
cairo Enable support for the cairo graphics library
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
icu Enable ICU (Internationalization Components for Unicode) support, using dev-libs/icu
java Add support for Java
jpeg Add JPEG image support
lapack Add support for the virtual/lapack numerical library
lto Enable Link-Time Optimization (LTO) to optimize the build
minimal Install a very minimal build (disables, for example, plugins, fonts, most drivers, non-critical features)
nls Add Native Language Support (using gettext - GNU locale utilities)
openmp Build support for the OpenMP (support parallel computing), requires >=sys-devel/gcc-4.2 built with USE="openmp"
perl Add optional support/bindings for the Perl language
png Add support for libpng (PNG images)
prefix Defines if a Gentoo Prefix offset installation is used
profile Add support for software performance analysis (will likely vary from ebuild to ebuild)
readline Enable support for libreadline, a GNU line-editing library that almost everyone wants
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
tiff Add support for the TIFF image format
tk Add support for Tk GUI toolkit

Emerge

root #emerge --ask dev-lang/R

Configuration

Compile flags for install.packages

At compile time, R remembers the CFLAGS and CXXFLAGS with which it was configured, storing them in $R_HOME/etc/Makeconf. However, certain CRAN packages may fail to compile with said flags, even if R itself compiled smoothly.

To rectify this, either change R's flags via /etc/portage/package.env, or work with the experimental R overlay.

Example: Removing LTO

Suppose that an attempt to install ggplot2 via install.packages("ggplot2") caused a compile time error due to -Werror=strict-aliasing, which is associated with LTO. To rectify this, use an env to demote this error to a warning. Since this warning often indicates LTO runtime issues, consider disabling lto as well.

FILE /etc/portage/env/no-ltoRemoving LTO
# These warnings were promoted to errors as they indicate likely runtime
# problems with LTO. Additively disable them since LTO is being removed.
WARNING_FLAGS="-Wno-error=odr -Wno-error=lto-type-mismatch -Wno-error=strict-aliasing"

CFLAGS="${CFLAGS} -fno-lto"
CXXFLAGS="${CXXFLAGS} -fno-lto"
FCFLAGS="${FCFLAGS} -fno-lto"
FFLAGS="${FFLAGS} -fno-lto"

USE="${USE} -lto"
FILE /etc/portage/package.env/RRemoving LTO
dev-lang/R no-lto

Reemerge R to propagate these changes.

root #emerge --ask dev-lang/R

Integration with other programs

ESS, or Emacs Speaks Statistics, is an Emacs mode that can edit R files and start R from within Emacs. To install:

root #emerge --ask app-emacs/ess

In Vim, the vim-r plugin integrates vim and R through tmux and provides support for editing R and send it to an R process. To install:

root #emerge --ask app-vim/vim-r