Commit ed74cd04 authored by Simon Pintarelli's avatar Simon Pintarelli

improve installer script

parent b311fb89
#!/usr/bin/bash
echo "Installing R-packages: dplyr, ggplot2, reshape, knitr, assertthat"
R --no-save < <(
echo "install.packages(c('dplyr', 'ggplot2', 'reshape', 'knitr', 'assertthat'),
repo=c('https://stat.ethz.ch/CRAN/'))")
export R_PROFILE=
export R_ENVIRON=
# argh this look ugly
#
echo "Installing R-packages: dplyr, ggplot2, reshape, knitr"
R --vanilla < scripts/install.R
echo "Installing required python packages"
pip3 install pandas xlwt --user
pip3 install pandas xlwt xlrd --user
# install packages if needed
list.of.packages <- c("ggplot2", "knitr", "reshape", "dplyr", "assertthat")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
# knitr
library(knitr)
knit('statistics.Rnw', quiet=TRUE)
# assemble the default user writeable library path (a bit ugly, but it seems to work)
home <- Sys.getenv('HOME')
rVersionString <- paste(R.version$platform, '-library', '/', R.version$major, '.', substr(R.version$minor, 1,1), sep='')
defaultUserLib <- paste(home, 'R', rVersionString, sep='/')
# make sure the directory exsits in the system
system(command = sprintf('mkdir -p %s', defaultUserLib))
# install
list.of.packages <- c("ggplot2", "knitr", "reshape", "dplyr", "xtable")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages, repos=c('https://stat.ethz.ch/CRAN/'), lib=c(defaultUserLib))
......@@ -37,7 +37,7 @@ dg <- 0.25 # grade interval
## piecewise linear grading scale, make sure to include maxpoints
int_points <- c(0, 21, 46, maxpoints)
int_grades <- c(1, 4, 6, 6)
max_points_per_taks <- c(10, 10, 10, 10) # max. no. of points per task
max_points_per_task <- c(10, 10, 10, 10) # max. no. of points per task, required to set axes limits
@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ================= END USER SETTINGS =================== %
......@@ -66,7 +66,7 @@ knit_hooks$set(r.opts=local({
}))
## (2) OUTPUT HOOK FUNCTION
## Define a custom output hook function. This function processes _all_
## evaluated chunks, but will return the same output as the usual one,
## UNLESS a 'codefig' argument appeared in the chunk's header. In that
## case, wrap the usual textual output in LaTeX code placing it in a
......@@ -115,12 +115,11 @@ library(dplyr)
library(ggplot2)
library(reshape)
library(xtable)
library(assertthat)
@
<<prepare data, echo=FALSE>>=
<<prepare data, echo=FALSE, message=FALSE>>=
## check user settings
assertthat(length(int_points) == length(int_grades))
stopifnot(length(int_points) == length(int_grades))
## read data
dset <- read.csv('marks.csv', encoding='ISO-8859-1')
......@@ -213,7 +212,7 @@ ppassed <- round(100*passed/ncand, 1)
\label{sec:point-statistics}
<<out,echo=FALSE,warning=FALSE, fig.width=5, fig.height=5, out.width="0.49\\linewidth",fig.cap="Point distribution (per task)",fig.show='hold',fig.subcap=c("Histogram","CDF"), fig.env="figure*", fig.pos='h!'>>=
axes_lim <- data.frame(sprintf('A%d', seq(length(max_points_per_taks))))
axes_lim <- data.frame(variable=sprintf('A%d', value=seq(length(max_points_per_task))), value=max_points_per_task)
ggplot(dset, aes(x=value)) +
geom_histogram(binwidth=1, alpha=0.8) +
geom_blank(data=axes_lim) +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment