#!/bin/bash

if [[ -f "$1" ]]; then

R -q --slave --vanilla <<EOF
print("================ Analyzing $1")
library(Hmisc)
print("spearman for improvement-potential vs. evolution-error")
DF=as.matrix(read.csv("$1",header=TRUE))
rcorr(DF[,4],DF[,6],type="spearman")

print("spearman for improvement-potential vs. steps")
DF=as.matrix(read.csv("$1",header=TRUE))
rcorr(DF[,4],DF[,5],type="spearman")

print("spearman for regularity vs. steps")
DF=as.matrix(read.csv("$1",header=TRUE))
rcorr(DF[,2],DF[,5],type="spearman")

print("spearman for variability vs. evolution-error")
DF=as.matrix(read.csv("$1",header=TRUE))
rcorr(DF[,3],DF[,6],type="spearman")
EOF

else

echo "Usage: $0 <Filename.csv>"
fi

