df <- read.csv("Clementines - student data.csv", sep=",")

df.leaves <- df[df$Leaves == 1,]
df.noleaves <- df[df$Leaves == 0,]

cat("Item", "\t", "F statistic", "\n", sep="")
for (column in names(df)[-1]) {
  x <- df.leaves[[column]]
  y <- df.noleaves[[column]]
  t <- t.test(x, y, var.equal=FALSE)$statistic
  F <- t ^ 2
  cat(column, "\t", sprintf("%.2f", F), "\n", sep="")
}

cat("\n")
adf <- df[-1]
adf.leaves <- df.leaves[-1]
adf.noleaves <- df.noleaves[-1]
cat("Cronbach's alpha\n")
cat("Overall: ", sprintf("%.3f", ltm::cronbach.alpha(adf)$alpha), "\n", sep="")
cat("With leaves: ", sprintf("%.3f", ltm::cronbach.alpha(adf.leaves)$alpha), "\n", sep="")
cat("No leaves: ", sprintf("%.3f", ltm::cronbach.alpha(adf.noleaves)$alpha), "\n", sep="")

# Table of all responses to items
table(as.matrix(df[-1]))
#  1   2   3   4   5   6   7   8   9  10 
#  6  14  18  16  48  85 122 116  57  18 # sums to 500

cat("\n")
df10 <- df
df10[df10 != 10] <- 0
cat("Count of responses of 10 per participant")   # \n not needed as print() throws a blank line to start
print(table(rowSums(df10)))

cat("\n")
# See what the most common number of repeated response values is for each row
max.ident <- rep(NA, nrow(df))
for (i in 1:nrow(df)) {
  max.ident[i] <- max(table(as.matrix(df[i, -1])))
}
cat("Count of most-repeated responses per participant")
print(table(max.ident + 0))   # "+0" to avoid print() including the variable name
