Maintaining a local repository for both Windows and Linux

r

Solution

It seems to me that you skipped one final step.

One needs

- A local package (which you have)

- Tarballs for Linux and binary packages for Windows (not sure)

- A local repository (which you started)

- Meta-data on your repository (which you seem to miss)

I do that at work for similar setup (some Windows, lots of Linux) via a simple script:

#!/bin/bash

## see e.g. 
## http://cran.r-project.org/doc/manuals/R-admin.html\
##                                       #Setting-up-a-package-repository
## http://stackoverflow.com/questions/2905650/creating-a-local-cran-repository

ver=3.00

rsync -vu *tar.gz /SomeServer/R/src/contrib/
rsync -vu *zip    /SomeServer/R/bin/windows/contrib/${ver}/ 

cd /SomeServer/R/src/contrib/
r -e 'tools::write_PACKAGES(".", type="source")' 

cd /SomeServer/R/bin/windows/contrib/${ver}/
r -e 'tools::write_PACKAGES(".", type="win.binary")' 

I use littler's r binary here, you could equally well use Rscript.

Problem

I have some R code that I'd like to share with other people in my office, and also run periodically on our servers. We all have Windows 7 desktops, and the servers run Red Hat Enterprise Linux. I've been through the docs, and I'm stuck. None of the following have all the necessary steps, detail the correct folder structure, or tell me how to build a Linux package, or build a Windows package on Linux. - http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf - http://cran.r-project.org/doc/manuals/R-admin.html#Setting-up-a-package-repository - Creating a local R package repository So I have my code in git. ``` $ mkdir ~/daveStuff $ cd ~/daveStuff $ git init $ git remote add origin git@davez0r.co:/opt/git/daveStuff.git $ git pull origin master ``` Now in my home directory I have this folder structure: ``` daveStuff |-- DESCRIPTION |-- R |-- stuff.R |-- exec |-- script.R ``` My description file looks like this: ``` Package: daveStuff Type: Package Title: What the package does (short line) Version: 1.0 Date: 2014-02-03 Author: Who wrote it Maintainer: Who to complain to <yourfault@somewhere.net> Description: More about what it does (maybe more than one line) License: What license is it under? ``` I'm running apache on one of my servers. So I added this: ``` /var/www/html/R/src/contrib/3.0/ ``` This correctly maps to the following, where I read any files I put there: ``` http://davez0r.co/R/src/contrib/3.0/ ``` What I'd like to be able to do is the following, from either Windows or Linux: ``` > install.packages("daveStuff", repos="http://davez0r.co/R", type="source") > library(daveStuff) ``` So first step is that I need to turn my library into a package. ``` $ cd ~ # one under the "daveStuff" directory $ R CMD build daveStuff ``` This creates a zip file: ``` ~/daveStuff_1.0.tar.gz ``` Now I copy that file to my repository location: ``` $ cp ~/daveStuff_1.0.tar.gz /var/www/html/R/src/contrib/3.0/ ``` Now if I go like this: ``` > install.packages("daveStuff", repos="http://davez0r.co/R", type="source") Warning in install.packages : unable to access index for repository http://davez0r.co/R/src/contrib ``` It gives me that error message saying that it can't find the package. So I create a package manifest: ``` $ cd /var/www/html/R/src/contrib # one under where I put the archive $ Rscript -e 'tools::write_PACKAGES(".", type="source", subdirs=TRUE)' ``` This gives me a `PACKAGES` file: ``` Package: daveStuff Version: 1.0 MD5sum: 817bbfedeb218ce0331dd7108408c5e6 NeedsCompilation: no Path: ./3.0 ``` Now it works when I try to load it: ``` > install.packages("daveStuff", repos="http://davez0r.co/R", type="source") ``` Unresolved issues: - I've lost the scripts that were in the `exec` directory. - Should I wrap these in functions and include them in the library? - Should I stick with `source` packages? - How do I make Windows binary packages on Linux?

Original source

Related problems