#!/usr/bin/Rscript # the strings containing the numbers have just been copy-and-pasted from the pdf, # that's why I use strsplit instead of c(..., ...) x <- as.numeric(strsplit("1 1 1 1 2 2 2 3 3 4", " ")[[1]]) y <- as.numeric(strsplit("5 3 5 7 3 3 1 1 1 1", " ")[[1]]) print(cor(x,y)) x <- as.numeric(strsplit("1 1 1 1 2 2 2 3 3 4", " ")[[1]]) y <- as.numeric(strsplit("1 2 1 3 1 4 1 2 2 3", " ")[[1]]) print(cor(x,y)) x <- as.numeric(strsplit("1 1 1 1 2 2 2 3 3 4", " ")[[1]]) y <- as.numeric(strsplit("2 2 2 2 4 4 4 6 6 8", " ")[[1]]) print(cor(x,y))