Installation

Reino Bruner edited this page Feb 16, 2017 · 75 revisions

v1.10.4 on CRAN 1 Feb 2017 Check status

install.packages("data.table")        # install it
library(data.table)                   # load it
example(data.table)                   # run some examples
?data.table                           # read
?fread                                # read
update.packages()                     # keep up to date


v1.10.5 in development from GitHub Build Status Latest news

Linux users usually have all tools already installed by default. Windows users should first install Rtools. Mac users will need the correct version of Xcode Command Line Tools, see OpenMP below.

Install data.table development version

From a clean session (make sure data.table package isn't loaded):

remove.packages("data.table")                         # First remove the current version
install.packages("data.table", type = "source",
    repos = "http://Rdatatable.github.io/data.table") # Then install devel version

If you would like to revert back to CRAN version, from a clean session, do:

remove.packages("data.table")         # First remove the current version
install.packages("data.table")        # Then reinstall the CRAN version

If you install the latest version from GitHub and start using a new feature, you may have to keep up with updates to ensure that subsequent changes (if any) don't break your code, since it's a development version. When we release to CRAN we are saying that we are happy with the changes and (in general) you can rely on them being there in future. However, if you hit a problem that the development version fixes then it is usually safe to simply upgrade to it. If it doesn't work out, you can very easily revert back to the CRAN version by removing the package and reinstalling (see commands above). Please also tell us about any such issues you encounter.

Windows binaries

Windows users without Rtools can still install development version of data.table by using binaries compiled during our Windows CI tests. Visit data.table on AppVeyor, click on one of two jobs (release/devel), go to artifacts tab. Copy link of data.table_*.zip file and paste it into call below.

install.packages("https://ci.appveyor.com/api/buildjobs/ymu75xfgk2vnfd30/artifacts/data.table_1.9.9.zip",repos=NULL)

OpenMP enabled compiler for Mac

Mac users will also additionally need OpenMP enabled compiler, but currently El Capitan v10.11.4 comes installed with clang, which is not.

First, ensure that you have command line tools installed. Do NOT skip this step. It is essential. See https://github.com/Rdatatable/data.table/issues/1692. From the terminal, type:

xcode-select --install

If you get an error message: xcode-select: error: command line tools are already installed, use "Software Update" to install updates, then you already have command line tools and can proceed to the next step. Else please follow the onscreen instructions and install it first.

Then, install homebrew if you have not already. After that, we can install the OpenMP enabled clang from the terminal by typing:

# update: seems like this installs clang with openmp support, 
# as pointed out by @botanize in #1817
brew update && brew install llvm

Following that add these lines to the file ~/.R/Makevars using your favourite text editor. It's likely you need to create the .R directory and the file Makevars in it if it doesn't already exist.

CC=/usr/local/opt/llvm/bin/clang -fopenmp
CXX=/usr/local/opt/llvm/bin/clang++
LDFLAGS=-L/usr/local/opt/gettext/lib -L/usr/local/opt/llvm/lib
CPPFLAGS=-I/usr/local/opt/gettext/include -I/usr/local/opt/llvm/include

Save and close the file. Then you should be all set on Mac. The -fopenmp tag on CC line might cause compile problems for other packages, notably stringi. Simply remove -fopenmp after compiling data.table.

Installing R via homebrew might cause additional problems during installation and is not recommended.

Why we recommend install.packages above rather than devtools::install_github

  1. This way you fetch the last version pushed to master which also passed full tests on a clean instance. This protects you from pulling master if it happens to be in a broken state. devtools always pulls master even if a recent push is failing tests. To do that for some reason (e.g. if we've just pushed a fix and you can't wait 15 mins for tests to complete, or if Travis checks themselves are not running):
    library(devtools)
    install_github("Rdatatable/data.table", build_vignettes=FALSE)

  2. As from devtools v1.10.0 (Feb 2016), install_github() checks the version number and doesn't update if the version number in master hasn't been bumped; i.e., similar to update.packages(). However, we only update the version number on release to CRAN. Therefore with install.packages(), you know for sure that it is fetching and installing the latest passing version from dev.