Kaggle Kernels allow users to run scripts against our competitions and datasets without having to download data or set up their environment. Here's an example:
This is the Dockerfile (etc.) used for building the image that runs R scripts on Kaggle. Here's the Docker image on Dockerhub.
To get started with this image, read our guide to using it yourself, or browse Kaggle Kernels for ideas.
We welcome pull requests if there are any packages you'd like to add!
We can merge your request quickly if you check that it builds correctly. Here's how to do that.
If you want a library that's, say, on GitHub but not yet on CRAN, then you can add it to package_installs.R
. To check that it will work, you can follow this example, which shows how to add a library called coolstuff
that's available from GitHub user nerdcha
.
me@my-computer:/home$ docker run --rm -it kaggle/rstats
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
[...etc...]
> library(devtools)
> install_github("nerdcha/coolstuff")
Downloading GitHub repo nerdcha/coolstuff@master
[...etc...]
** testing if installed package can be loaded
* DONE (coolstuff)
> library(coolstuff)
>
Everything worked, so we can add the line install_github("nerdcha/coolstuff")
to package_installs.R
and submit the pull request.
Some libraries will need extra system support to work. Installing them follows a pretty similar pattern; just try whatever prerequisites the package maintainer says are needed for a Linux system. For example, if the coolstuff
package says to run apt-get install libcool-dev
first, then you can test it in the following way.
me@my-computer:/home$ docker run --rm -it kaggle/rstats /bin/bash
root@2dd4317c8799:/# apt-get update
Ign:1 http://ftp.de.debian.org/debian jessie InRelease
[...]
root@2dd4317c8799:/# apt-get install libcool-dev
Reading package lists... Done
[...]
root@2dd4317c8799:/# R
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
[...]
> library(devtools)
> install_github("nerdcha/coolstuff")
Downloading GitHub repo nerdcha/coolstuff@master
[...]
** testing if installed package can be loaded
* DONE (coolstuff)
> library(coolstuff)
>
If that's all working as expected, then you can add apt-get install libcool-dev
to the end of the Dockerfile
, and install_github("nerdcha/coolstuff")
to package_installs.R
.