# ferdo R Lab — Lesson 0: programming foundations / Programlamanin temelleri
# Original independent exercise, synthetic observations only.
# No packages needed. Run one section at a time in RStudio.

# 1 / Read, predict, run (Oku, tahmin et, calistir)
scores <- c(12, 10, 14, NA, 9)
print(length(scores))
print(mean(scores))
print(mean(scores, na.rm = TRUE))
print(sum(!is.na(scores)))

# 2 / Understand individual change (Bireysel degisimi anla)
id <- c("A","B","C","D","E")
before <- c(12, 10, 14, NA, 9)
after <- c(14, 13, 13, 15, 12)
delta <- after - before
print(data.frame(id, before, after, delta))

# TODO A: Count valid paired changes using !is.na(delta).
# TODO B: Count positive and negative deltas, ignoring NA.
# TODO C: Calculate the mean of valid changes.
# TODO D: In a comment, compare the mean of all posttests against
#         the mean of the matched individual changes. Are they equivalent?
# TODO E: In a comment, explain why a change cannot prove causation.

# 3 / Find and explain the bug (Hatayi bul ve acikla)
average_before <- mean(before)
print(average_before)
# TODO F: Fix the missing-data issue.
# TODO G: What question does the fixed calculation answer?
# Do not upload real participant data to public code examples.
