1 Setup the Computing Environment
1.1 Install R
We recommend install both regular R and the Microsoft R-Open. Even though the later is better optimized, it fails to install packages with compiled code, (see https://github.com/Microsoft/microsoft-r-open/issues/17). The solution is to install packages in regular R and use a shared library directory for both R instances.
We recommend install R before install Anaconda Python, as the later will pollute the system environment (for instance, it might throw the libcurl version error.)
After downloading the source code from https://www.r-project.org:
# configuration
# run ./configure --help to see all available options
./configure --prefix=/apps/R/R-x.y.z --enable-memory-profiling \
--enable-R-profiling \
--enable-R-shlib
# build and install R
make
make install
# Specify the directory for R packages. This is only needed if we
# want to install Microsoft R-Open as well.
mkdir -p /apps/R/lib-x.y.z
echo '.libPaths("/apps/R/lib-x.y.z")' >> ~/.Rprofile
# now run R
/apps/R/R-x.y.z/bin/R --version1.2 Install Python
1.3 Writing Notes with R::bookdown
1.3.1 Create a new book on Github
Follow the steps below to write a book named Statistical Models. First initiate the working directory:
mkdir StatisticalModels
cd StatisticalModelsCreate file StatisticalModels.Rproj. This enables Build -> Build Book in the RStudio IDE.
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: knitr
LaTeX: pdfLaTeX
AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
BuildType: Website
Create file index.Rmd:
---
title: "Statistical Models"
author: "Yue Zhao"
date: "2017-12-26"
site: bookdown::bookdown_site
output: bookdown::gitbook
documentclass: book
biblio-style: apalike
link-citations: yes
github-repo: giantwhale/StatisticalModels
description: "Statistical Models"
---
# Introduction {-}
omitted ...
Create file _bookdown.yml, so bookdown knows to output html files to the docs folder (need by github).
output_dir: "docs"
Now we can start writing notes in .Rmd format.
To enable github page, click on Settings, then go to GitHub Pages Session -> Source. Change None to Master Branch /docs folder. Once done, a link will appear in the same section.
1.4 Continuous Integration with Travis
Travis works well with github. It helps us build, test and deploy so we can focus on coding. The workflow is as the following:
. User runs build. . Travis CI clones the GitHub repo into a brand new virtual env, build and test the code. . If one or more tasks failed, the build is considered broken. . If none of the tasks failed, the build is considered passed. Travis then deploys the code.
Unfinished …