This is a follow up question to Kikapp's answer.
I want to remove participant IDs which lack all the time-points. In other way around, I want to select rows which have all the four time (11, 21, 31, 41). See the sample data dropbox link
Here is my try based on Kikapp's answer. For some reason, it doesn't work. Let me know how to make it better.
data2 <- df[df$ID %in% names(table(df$ID))[table(df$ID) > 3],]
I get 4695 rows or objects or IDs for time == 11, time == 21,time == 41 while 4693 for time == 31; however, I want they should be equal.
do.call(rbind,Filter(function(x) { length(unique(x[,2])) == 4 },split(df, df$ID))).df %>% group_by(ID) %>% dplyr::filter(length(unique(time)) == 4) %>% data.frame()withdplyr.time==31. Actually all four time-points (11,21,31,41) should have same number of IDs or rows or objects. Withdata2 <- df[df$ID %in% names(table(df$ID))[table(df$ID) > 3],]code or yoursdf %>% group_by(ID) %>% dplyr::filter(length(unique(time)) == 4) %>% data.frame()code, I get 4695 rows or objects or IDs for 11, 21,41 while 4693 for 31 time.timevalues of32. You did not mention that there are rows with values of32fortime.32.