Installation

Jan Gorecki edited this page Sep 20, 2018 · 113 revisions

v1.11.6 on CRAN 19 September 2018

Linux, Mac and Windows

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


v1.11.7 in development Build Status

Please click and read latest news and keep up to date. That page is updated live as we push changes in development. 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. It is safe to simply upgrade to development version and give it a go. If it doesn't work out, you can very easily revert back to the CRAN version by removing the package and reinstalling using the commands above.

Windows

No tools are needed. A compiled Windows .zip file is created after every change in development that passes the test suite.
On Windows, when upgrading any package that uses compiled code, it appears to be important to close all R sessions before upgrading. This releases all locks that Windows holds on dlls. To be really sure, reboot too. Then open a new fresh R session. Some users have an .Rprofile file that automatically loads data.table whenever any R sessions starts. You probably do not have an .Rprofile file but if you do, and it loads any packages (which themselves might load data.table), either temporarily rename .Rprofile or pass --vanilla when starting R to prevent it from running .Rprofile. Once you have a single fresh R session without data.table loaded proceed to installation.

  • Install from GitLab

We run Windows builds on GitLab CI where windows binaries are published in a more R-native way, thus you can use below commands.

install.packages("data.table", repos="https://Rdatatable.gitlab.io/data.table")
# or, which install only if newer version (by git commit hash) is available
data.table::update.dev.pkg(repo="https://Rdatatable.gitlab.io/data.table")
  • Install from AppVeyor

Click Windows .zip. The two job names at the bottom are clickable. Click on the job containing "R_VERSION=release". On the next page, click the ARTIFACTS tab. Scroll down to the bottom and there you should see the data.table_<ver>.zip file. Click that .zip filename to download it to your Downloads folder. Notice that the HTML address of this page changes every time we push a change to development. That's why we can't just link to the .zip file directly; you have to click through those pages. In fact, the history of Windows .zip binaries from development is available there should you need a binary as of a few weeks ago, for example.
Install the data.table_<ver>.zip file you downloaded using the menu in the R GUI that you use, or type the following command :

install.packages("data.table_<ver>.zip", repos=NULL)
  • To test your installation
require(data.table)
test.data.table()

If test.data.table() fails then you know the installation has not worked properly. Typical problems on Windows involve functions missing or parameters mismatching. These problems can result in a crash. Reboot your Windows machine to clear all dll locks and reinstall the .zip again. test.data.table() is a reliable way to test your installation. The full suite of over 5,000 tests runs locally on your machine and should not take more than 2 minutes.

Linux and Mac

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

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

remove.packages("data.table")
install.packages("data.table", type = "source",
    repos = "http://Rdatatable.github.io/data.table")

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

remove.packages("data.table")
install.packages("data.table")

Why install.packages above rather than devtools::install_github

This way you fetch the last version pushed to master which also passed the full test suite. 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 or AppVeyor themselves are not running) :
library(devtools)
install_github("Rdatatable/data.table", build_vignettes=FALSE)

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.

Option 1 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

Option 2 brew less install

wget http://releases.llvm.org/5.0.1/clang+llvm-5.0.1-x86_64-apple-darwin.tar.xz
sudo tar -xzvf clang+llvm-5.0.1-x86_64-apple-darwin.tar.xz -C/usr/local --strip-components 1
sudo rm clang+llvm-5.0.1-x86_64-apple-darwin.tar.xz

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.

# if you downloaded llvm manually above, replace with your chosen NEW_PATH/clang
LLVM_LOC = /usr/local/opt/llvm
CC=$(LLVM_LOC)/bin/clang -fopenmp
CXX=$(LLVM_LOC)/bin/clang++ -fopenmp
# -O3 should be faster than -O2 (default) level optimisation ..
CFLAGS=-g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe
CXXFLAGS=-g -O3 -Wall -pedantic -std=c++11 -mtune=native -pipe
LDFLAGS=-L/usr/local/opt/gettext/lib -L$(LLVM_LOC)/lib -Wl,-rpath,$(LLVM_LOC)/lib
CPPFLAGS=-I/usr/local/opt/gettext/include -I$(LLVM_LOC)/include

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

Installing R via homebrew might cause additional problems during installation and is not recommended. However, if you want to install it using Homebrew you can find extended instructions to install R and data.table in this blog post.

It has been reported that gettext is needed to be installed too. There are several posts online on how to do that, and it may depend on which version of MacOS you have.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.