options(scipen = 999)
setwd("C:/Users/irina/Documents/DND/EOHI/eohi2")
data <- read.csv("eohi2.csv")

cat("\n================================================================================\n")
cat("VERIFICATION SUMMARY: ALL 11 MEAN VARIABLES (Rows 1-2)\n")
cat("================================================================================\n\n")

for (i in 1:2) {
  cat("-------------------------- ROW", i, "----------------------------\n\n")
  
  cat("NARROW-SCOPE MEANS (15 items each):\n")
  cat("-----------------------------------\n")
  
  # Set 1: NPast_5_mean
  v1 <- as.numeric(data[i, c('NPast_5_pref_read','NPast_5_pref_music','NPast_5_pref_TV','NPast_5_pref_nap','NPast_5_pref_travel','NPast_5_pers_extravert','NPast_5_pers_critical','NPast_5_pers_dependable','NPast_5_pers_anxious','NPast_5_pers_complex','NPast_5_val_obey','NPast_5_val_trad','NPast_5_val_opinion','NPast_5_val_performance','NPast_5_val_justice')])
  cat(sprintf("1. NPast_5_mean:     Sum=%2d, Calc=%.10f, Stored=%.10f\n", sum(v1), mean(v1), data[i,'NPast_5_mean']))
  
  # Set 2: NPast_10_mean
  v2 <- as.numeric(data[i, c('NPast_10_pref_read','NPast_10_pref_music','NPast_10_pref_TV','NPast_10_pref_nap','NPast_10_pref_travel','NPast_10_pers_extravert','NPast_10_pers_critical','NPast_10_pers_dependable','NPast_10_pers_anxious','NPast_10_pers_complex','NPast_10_val_obey','NPast_10_val_trad','NPast_10_val_opinion','NPast_10_val_performance','NPast_10_val_justice')])
  cat(sprintf("2. NPast_10_mean:    Sum=%2d, Calc=%.10f, Stored=%.10f\n", sum(v2), mean(v2), data[i,'NPast_10_mean']))
  
  # Set 3: NFut_5_mean
  v3 <- as.numeric(data[i, c('NFut_5_pref_read','NFut_5_pref_music','NFut_5_pref_TV','NFut_5_pref_nap','NFut_5_pref_travel','NFut_5_pers_extravert','NFut_5_pers_critical','NFut_5_pers_dependable','NFut_5_pers_anxious','NFut_5_pers_complex','NFut_5_val_obey','NFut_5_val_trad','NFut_5_val_opinion','NFut_5_val_performance','NFut_5_val_justice')])
  cat(sprintf("3. NFut_5_mean:      Sum=%2d, Calc=%.10f, Stored=%.10f\n", sum(v3), mean(v3), data[i,'NFut_5_mean']))
  
  # Set 4: NFut_10_mean
  v4 <- as.numeric(data[i, c('NFut_10_pref_read','NFut_10_pref_music','NFut_10_pref_TV','NFut_10_pref_nap','NFut_10_pref_travel','NFut_10_pers_extravert','NFut_10_pers_critical','NFut_10_pers_dependable','NFut_10_pers_anxious','NFut_10_pers_complex','NFut_10_val_obey','NFut_10_val_trad','NFut_10_val_opinion','NFut_10_val_performance','NFut_10_val_justice')])
  cat(sprintf("4. NFut_10_mean:     Sum=%2d, Calc=%.10f, Stored=%.10f\n", sum(v4), mean(v4), data[i,'NFut_10_mean']))
  
  # Set 5: X5.10past_mean
  v5 <- as.numeric(data[i, c('X5.10past_pref_read','X5.10past_pref_music','X5.10past_pref_TV','X5.10past_pref_nap','X5.10past_pref_travel','X5.10past_pers_extravert','X5.10past_pers_critical','X5.10past_pers_dependable','X5.10past_pers_anxious','X5.10past_pers_complex','X5.10past_val_obey','X5.10past_val_trad','X5.10past_val_opinion','X5.10past_val_performance','X5.10past_val_justice')])
  cat(sprintf("5. X5.10past_mean:   Sum=%2d, Calc=%.10f, Stored=%.10f\n", sum(v5), mean(v5), data[i,'X5.10past_mean']))
  
  # Set 6: X5.10fut_mean
  v6 <- as.numeric(data[i, c('X5.10fut_pref_read','X5.10fut_pref_music','X5.10fut_pref_TV','X5.10fut_pref_nap','X5.10fut_pref_travel','X5.10fut_pers_extravert','X5.10fut_pers_critical','X5.10fut_pers_dependable','X5.10fut_pers_anxious','X5.10fut_pers_complex','X5.10fut_val_obey','X5.10fut_val_trad','X5.10fut_val_opinion','X5.10fut_val_performance','X5.10fut_val_justice')])
  cat(sprintf("6. X5.10fut_mean:    Sum=%2d, Calc=%.10f, Stored=%.10f\n", sum(v6), mean(v6), data[i,'X5.10fut_mean']))
  
  cat("\nGLOBAL-SCOPE MEANS (30 items each):\n")
  cat("-----------------------------------\n")
  
  # Set 7: NPast_global_mean
  v7 <- c(v1, v2)
  cat(sprintf("7. NPast_global:     Sum=%2d, Calc=%.10f, Stored=%.10f\n", sum(v7), mean(v7), data[i,'NPast_global_mean']))
  
  # Set 8: NFut_global_mean
  v8 <- c(v3, v4)
  cat(sprintf("8. NFut_global:      Sum=%2d, Calc=%.10f, Stored=%.10f\n", sum(v8), mean(v8), data[i,'NFut_global_mean']))
  
  # Set 9: X5.10_global_mean
  v9 <- c(v5, v6)
  cat(sprintf("9. X5.10_global:     Sum=%2d, Calc=%.10f, Stored=%.10f\n", sum(v9), mean(v9), data[i,'X5.10_global_mean']))
  
  # Set 10: N5_global_mean
  v10 <- c(v1, v3)
  cat(sprintf("10. N5_global:       Sum=%2d, Calc=%.10f, Stored=%.10f\n", sum(v10), mean(v10), data[i,'N5_global_mean']))
  
  # Set 11: N10_global_mean
  v11 <- c(v2, v4)
  cat(sprintf("11. N10_global:      Sum=%2d, Calc=%.10f, Stored=%.10f\n", sum(v11), mean(v11), data[i,'N10_global_mean']))
  
  cat("\n")
}

cat("================================================================================\n")
cat("ALL CALCULATIONS VERIFIED!\n")
cat("================================================================================\n")

