I have a large data frame for which I want to be able to plot a histogram of the number of viable sessions -- indicated by any value other than NA -- for all participants in order to determine whether they are completing a sufficient number of sessions to be included in analysis and whether there is a clear cut-off point for how many sessions most people have scores for. Each participant should complete 10 sessions for the study, but some have missing sessions, indicated by NA.
The real data frame is large and contains participant data I can't show, but I've recreated a smaller sample version here that has the essential columns which are the participant ID, the score they got during each session, and the session number.
Code to recreate the data frame:
dat <- cbind(c(rep(1:3,10)), c(rep(c(12, 32, NA, 44, 45, NA, NA, 8, 54, NA, NA, 12, 13, 14, NA),2)), c(rep(1,3), rep(2,3), rep(3,3), rep(4,3), rep(5,3), rep(6,3), rep(7,3), rep(8,3), rep(9,3), rep(10,3)))
colnames(dat) <- c("ID", "score", "session.num")
Thank you in advance for your help. Please let me know if my question requires clarification.