I need *devtools* because I need the function *install\_github* to install the non-CRAN package *digitize* [here](https://github.com/tpoisot/digitize).
I installed `R` by 

```
sudo apt-get install r-cran-robustbase

```

I did not install R's packages right away, as terdon's answer proposes, but I could correct the permissions:

```
sudo chmod 755 /usr/lib/R/site-library/

```

which I think is the default setting. 
I then had to do as rcs' answer proposes, to successfully install `devtools` and `tpoisot/digitize` but only with

```
sudo apt-get install libssl-dev
sudo apt-get install libcurl4-openssl-dev
R
install.packages('httr')
install.packages('git2r')
install.packages('devtools')
library(devtools)
install.packages('readbitmap')
install_github('tpoisot/digitize')

```

The output of the last command can be 

```
Skipping install for github remote, the SHA1 (d16e28b9) has not changed since last install.
  Use `force = TRUE` to force installation

```

Do `install_github('tpoisot/digitize', force = TRUE)` but you may get

```
...
'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet  \
  CMD INSTALL '/tmp/RtmpX8eOLX/devtools57475d25a113/tpoisot-digitize-d16e28b'  \
  --library='/usr/local/lib/R/site-library' --install-tests 

Error: ERROR: no permission to install to directory ‘/usr/local/lib/R/site-library’
Error: Command failed (1)

```

I could not find a way to install digitize without `sudo`. So do `sudo R`, and repeat the same and you get 

```
...
'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet  \
  CMD INSTALL '/tmp/RtmpAlAT4e/devtools57e864e8c490/tpoisot-digitize-d16e28b'  \
  --library='/usr/local/lib/R/site-library' --install-tests 

* installing *source* package ‘digitize’ ...
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (digitize)

```

Add `masi` to the existing group `staff` to work without `sudo` in `R`; which you need also in a fresh installation

```
sudo usermod -a -G staff masi

```

Tests of the installation
-------------------------

1. I follow the guide [here](http://lukemiller.org/index.php/2011/06/digitizing-data-from-old-plots-using-digitize/). I start `R` in `$HOME/Pictures/` without `sudo` and use their test image [here](http://lukemiller.org/wp-content/uploads/2011/06/Rintro-snail1.jpg).
2. Select four points in the axes with mouse `cal = digitize::ReadAndCal('Rintro-snail1.jpg')`

[![enter image description here](https://i.stack.imgur.com/YtPlN.png)](https://i.stack.imgur.com/YtPlN.png)

3. Do `data.points = digitize::DigitData(col = 'red')` and choose manually points which are your data points

[![enter image description here](https://i.stack.imgur.com/rRUu2.png)](https://i.stack.imgur.com/rRUu2.png)

4. I close the Plot window by doing second-click.
5. Do `df = digitize::Calibrate(data.points, cal, 0.1, 0.4, 0.0, 0.6)` and seeing `df`

```
       x  y
1  71.50 NA
2  65.65 NA
...
24 26.80 NA

```

Doing `head(df)` 

```
      x  y
1 71.50 NA
2 65.65 NA
3 64.60 NA
4 60.85 NA
5 59.05 NA
6 58.15 NA

```

Installation Details
--------------------

* In `R` and without `sudo`

```
> .Library
[1] "/usr/lib/R/library"
> > .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"      
[3] "/usr/lib/R/library"  

```
* Command `ls /usr/lib/R/library/` which does not list `devtools`. Why?

```
base       compiler   grid        methods   rpart    survival
boot       datasets   KernSmooth  mgcv      spatial  tcltk
class      foreign    lattice     nlme      splines  tools
cluster    graphics   MASS        nnet      stats    translations
codetools  grDevices  Matrix      parallel  stats4   utils

```
* Command `ls -la /usr/local/lib/R/` 

```
total 12
drwxrwsr-x 3 root staff 4096 touko 19 22:25 .
drwxr-xr-x 5 root root  4096 touko 19 22:25 ..
drwxrwsr-x 2 root staff 4096 touko 19 22:25 site-library

```
* Command `ls -la /usr/local/lib/`

```
total 20
drwxr-xr-x  5 root root  4096 touko 19 22:25 .
drwxr-xr-x 14 root root  4096 touko 19 22:13 ..
drwxrwsr-x  4 root staff 4096 huhti 21 01:13 python2.7
drwxrwsr-x  3 root staff 4096 huhti 21 01:08 python3.5
drwxrwsr-x  3 root staff 4096 touko 19 22:25 R

```
* Command `R_LIBS_USER="/usr/local/lib/R/site-library/" R`

```
 R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
 Copyright (C) 2015 The R Foundation for Statistical Computing
 Platform: x86_64-pc-linux-gnu (64-bit)
 ...

```
* `library(devtools)` gets loaded

Differential tools
------------------

* This project is more popular and can work better <https://github.com/markummitchell/engauge-digitizer>

Reasons for previous bugs

* No clean system: systems which were upgraded from 14.04, 15.10, etc.
* Messed up permissions/owners because of the previous thing.
* Own mistakes in the process.
* No backups in the case of failure.
* ...
* missing docs

System: Ubuntu 16.04 64 bit in a clean installation  

Hardware: Dell PC 2013, Macbook Air 2013-mid, ...