Rev 5280 | Blame | Last modification | View Log | Download | RSS feed
#!/bin/sh##--- NEW: ----------#### Given a list of files of the form .../.../<name>.R,#### Produce one large file, i.e. write to stdout## 'cat'ting the files together with## 1) Putting a HEADER in front## 2) Wrapping every file in order to be more order independent## 3) appending a FOOTER ...## Should work WHEREVER this is called from :(cd `dirname $0`/..R_HOME=`pwd`; export R_HOME)R_HOME=`cd ${R_HOME}; pwd` # absolutePKG=$1; shift;FILES="$@"#Dbg> echo "R_HOME=$R_HOME"; echo#Dbg> echo "FILES=$FILES"; echo ; echo; exit## 1) ---- Header ----(cat <<_EOF_..CheckEnv <- new.env()assign("ptime",proc.time(), env=..CheckEnv)postscript('PKG-Examples.ps')assign("par.postscript", par(no.readonly = TRUE), env=..CheckEnv)options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly"))_EOF_) | sed "s/PKG/${PKG}/"if [ "$PKG" != "base" ]; then echo "library('$PKG')" ; fi## 2) ---- edit a few of these files:for file in $FILESdobf=`basename $file .R`if [ -n "`grep '_ Examples _' $file`" ]thenecho 'll <- ls(all=TRUE);rm(list= ll[ll != "..CheckEnv"]); .Random.seed <- c(0,rep(7654,3))'elseif [ "$USER" = maechler ];then## Remind certain people to upgrade the online helpecho "'$bf' has no Examples.." >& 2fificat $fileif [ -n "`grep 'par(' $file`" ];then## if there were 'par(..)' calls, now reset them:echo 'par(get("par.postscript",env=..CheckEnv))'fiif [ -n "`grep 'options(contrasts' $file`" ];then## if contrasts were set, now reset them:echo 'options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly"))'fidone## 3) ---- Footer ----cat <<_EOF_cat("Time elapsed: ", proc.time() - get("ptime",env=..CheckEnv),"\n")dev.off(); quit('no')_EOF_