#!/usr/bin/Rscript
par(mfrow=c(2,1))
data_points <- c(rep(0,31), rep(-1,5), rep(1,4))
print(table(data_points))
cat(data_points, "\nThis dataset has a mean of", mean(data_points), "and a SD of", sd(data_points), "\n")
data_points_outside <- data_points[which(data_points > mean(data_points)+2*sd(data_points) | data_points < mean(data_points)-2*sd(data_points))]
cat(length(data_points_outside), "data points are more than 2 SD away from the mean:\n", data_points_outside, "\n")
plot(table(data_points), main="data points more than 2 SD away from the mean")
abline(v=mean(data_points), col="blue")
abline(v=c(mean(data_points)-2*sd(data_points), mean(data_points)+2*sd(data_points)), lty=3)
data_points <- c(rep(0,38), -1, 1)
print(table(data_points))
cat(data_points, "\nThis dataset has a mean of", mean(data_points), "and a SD of", sd(data_points), "\n")
data_points_inside <- data_points[which(data_points < mean(data_points)+1*sd(data_points) & data_points > mean(data_points)-1*sd(data_points))]
cat(length(data_points_inside), "data points are less than 1 SD away from the mean:\n", data_points_inside, "\n")
plot(table(data_points), main="data points less than 1 SD away from the mean")
abline(v=mean(data_points), col="blue")
abline(v=c(mean(data_points)-sd(data_points), mean(data_points)+sd(data_points)), lty=3)