Brett Klamer

Portable Statistical Document Folder

When working in an academic or corporate setting using Windows, it's useful to have a similar working environment that you would have on your own computer. Group policies and non-administrator accounts often prevent you from installing the software you may need. The following will allow you to program using R and write documents with knitr.

Limitations

  1. Absolute file path names are an issue. Several configuration settings may need to be changed if you transfer the file from computer to computer.
  2. LyX has problems with UNC path names
  3. Some useful programs for R, such as JAGS, may not work as portable programs
  4. There are many variations of what I've laid out. modify the programs and settings to your needs.

1. Create the portable folder

create a folder in a convenient location with the following hierarchy:

2. Download items

Download the following to the install_files folder:

3. Extract and install

Install R

Install R to portable_stat/r.

  1. Uncheck Registry entries options.

Extract RStudio

Extract RStudio to portable_stat/rstudio.

Install Rtools

Install Rtools to portable_stat/Rtools.

  1. Check R toolset and Cygwin DLLs
  2. uncheck editing system path and saving version number in registry

Extract MikTeX Portable

Install LyX

Install LyX to portable_stat/lyx. Detailed instructions are on http://wiki.lyx.org/Windows/PortableInstallation.

  1. Unfortunately the installer checks for previous versions and wont run if any are detected. This will then need to be installed from another computer. Or, possibly a better solution, is to copy the LyX directory currently installed over to the portable folder and modify the settings.
  2. Choose Install just for me
  3. Change install directory to portable_stat/lyx
  4. Uncheck file associations and desktop icon
  5. Don't create shortcuts
  6. Don use Latex

Extract Texmaker

Extract Texmaker to portable_stat/texmaker.

4. Delete install_files folder

Now that we're done installing/extracting everything, you can delete the install_files folder

5. Get everything working

RStudio

  1. Create shortcut in portable_stat/
    • use portable_stat/rstudio/bin/rstudio.exe
  2. In Tools -> Options -> General, change R path to your_path/portable_stat/r
  3. Make sure the install library is your_path/portable_stat/r/library or your_path/portable_stat/rstudio/R/library

LyX

  1. Open the portable_stat\lyx\Resources\lyxrc.dist file in notepad or wordpad, then change the path_prefix line to:
    \path_prefix "$LyXDir\bin;$LyXDir\python;$LyXDir\imagemagick;$LyXDir\ghostscript;$LyXDir\miktex\bin\win32"
  2. Create a new textfile in portable_stat/lyx and paste the following line in it: start bin\LyX.exe -userdir "userdir". Save it, and rename it to startLyX.bat (without the .txt extension!)
  3. Execute the startLyx.bat file. This will start lyx. Click yes when you're asked if you want to create the userdirectory.
  4. Create a shortcut to startLyx.bat in the main level of the folder

Texmaker

  1. Create shortcut in portable_stat/
    • use portable_stat/texmaker/texmaker.exe
  2. Update and download needed packages. Some packages you might want are
    • latexmk (helps automate compiling process)
    • biber (a BibTeX replacement for users of BibLaTeX)
    • biblatex (bibliographic facilities)
  3. There are two ways to change the file path configuration.
    • Options -> Configure Texmaker and then modify
      • Latex: your_path/portable_stat/lyx/miktex/bin/win32/latex.exe
      • PdfLatex: your_path/portable_stat/lyx/miktex/bin/win32/pdflatex.exe
      • Latexmk: your_path/portable_stat/lyx/miktex/bin/win32/latexmk.exe
      • biblatex: your_path/portable_stat/lyx/miktex/bin/win32/biblatex.exe or your_path/portable_stat/lyx/miktex/bin/win32/biber.exe
      • makeindex: your_path/portable_stat/lyx/miktex/bin/win32/makeindex.exe
      • Ghostscript: your_path/portable_stat/lyx/miktex/tlpkg/tlgs/bin/gswin32c.exe
      • R Sweave: (directed to knitr instead)"your_path/portable_stat/r/bin/x64/r.exe" -e "knitr::knit2pdf('%.Rnw')"
    • Or modify portable_stat/texmaker/texmaker.ini. Find the section that looks like this
      Tools\ExtraPath=
      Tools\OutputDir=false
      Tools\Quick%20Mode=3
      Tools\Latex="latex -interaction=nonstopmode %.tex"
      Tools\Dvi=\"C:/Program Files/MiKTeX 2.9/miktex/bin/yap.exe\" %.dvi
      Tools\Dvips=dvips -o %.ps %.dvi
      Tools\Ps=\"C:/Program Files/Ghostgum/gsview/gsview32.exe\" %.ps
      Tools\Ps2pdf=ps2pdf %.ps
      Tools\Makeindex=makeindex %.idx
      Tools\Bibtex=bibtex %
      Tools\Pdflatex="pdflatex -synctex=1 -interaction=nonstopmode %.tex"
      Tools\Xelatex="xelatex -synctex=1 -interaction=nonstopmode %.tex"
      Tools\Pdf=\"C:/Program Files/Adobe/Reader 10.0/Reader/AcroRd32.exe\" %.pdf
      Tools\Dvipdf=dvipdfm %.dvi
      Tools\Metapost="mpost --interaction nonstopmode "
      Tools\Ghostscript=\"C:/Program Files/gs/gs9.05/bin/gswin32c.exe\"
      Tools\Asymptote=\"C:/Program Files/Asymptote/asy.exe\" %.asy
      Tools\Latexmk="latexmk -e \"$pdflatex=q/pdflatex -synctex=1 -interaction=nonstopmode/\" -pdf %.tex"
      Tools\Sweave=C:/Program Files/R/R-2.13.2/bin/R.exe CMD Sweave %.Rnw
      Tools\Texdoc=texdoc
      Tools\HtOptions="\"\" \"\" \"\" -interaction=nonstopmode"
      Tools\Htlatex=htlatex
      Tools\Userquick="latex -interaction=nonstopmode %.tex|bibtex %.aux|latex -interaction=nonstopmode %.tex|latex -interaction=nonstopmode %.tex|xdvi %.dvi"
      Tools\Run=0
      Tools\View=2
      Tools\IntegratedPdfViewer=true
      Tools\PdfInternalViewEmbed=false
      Tools\SingleViewerInstance=false
      and change it to (don't forget to modify your_path/)
      Tools\ExtraPath=
      Tools\OutputDir=false
      Tools\Quick%20Mode=3
      Tools\Latex="\"your_path/portable_stat/lyx/miktex/bin/win32/latex.exe\" -interaction=nonstopmode %.tex"
      Tools\Dvi=\"C:/Program Files/MiKTeX 2.9/miktex/bin/yap.exe\" %.dvi
      Tools\Dvips=dvips -o %.ps %.dvi
      Tools\Ps=\"C:/Program Files/Ghostgum/gsview/gsview32.exe\" %.ps
      Tools\Ps2pdf=ps2pdf %.ps
      Tools\Makeindex=\"your_path/portable_stat/lyx/miktex/bin/win32/makeindex.exe\" %.idx
      Tools\Bibtex=\"your_path/portable_stat/lyx/miktex/bin/win32/biber.exe\" %
      Tools\Pdflatex="\"your_path/portable_stat/lyx/miktex/bin/win32/pdflatex.exe\" -interaction=nonstopmode %.tex"
      Tools\Xelatex="xelatex -synctex=1 -interaction=nonstopmode %.tex"
      Tools\Pdf=\"C:/Program Files/Adobe/Reader 10.0/Reader/AcroRd32.exe\" %.pdf
      Tools\Dvipdf=dvipdfm %.dvi
      Tools\Metapost="mpost --interaction nonstopmode "
      Tools\Ghostscript=\"your_path/portable_stat/lyx/miktex/tlpkg/tlgs/bin/gswin32c.exe\"
      Tools\Asymptote=\"C:/Program Files/Asymptote/asy.exe\" %.asy
      Tools\Latexmk="\"your_path/portable_stat/lyx/miktex/bin/win32/latexmk.exe\" -e \"$pdflatex=q/pdflatex -interaction=nonstopmode/\" -pdf %.tex"
      Tools\Sweave=\"your_path/portable_stat/r/bin/x64/r.exe\"  -e \"knitr::knit2pdf('%.Rnw')\"
      Tools\Texdoc=texdoc
      Tools\HtOptions="\"\" \"\" \"\" -interaction=nonstopmode"
      Tools\Htlatex=htlatex
      Tools\Userquick="latex -interaction=nonstopmode %.tex|bibtex %.aux|latex -interaction=nonstopmode %.tex|latex -interaction=nonstopmode %.tex|xdvi %.dvi"
      Tools\Run=0
      Tools\View=2
      Tools\IntegratedPdfViewer=true
      Tools\PdfInternalViewEmbed=false
      Tools\SingleViewerInstance=false