I have a repeated measures data set. I need to remove all Participants where the number of observations for that individual is less than 3. What is the best way to do this?
x <- c(9, 9, 9, 11, 11, 23, 23, 23, 23, 45, 45, 45, 56, 56)
Here 11 and 56 need to be removed from the data. So far I have created a data frame with all the obs that I want to keep but not sure how to manipulate my data set using the new data frame
x <- as.data.frame(table(x))
x1 <- x[x$Freq > 2,]
One more for the
ave()
function :In an answer to your comment, you should perform it like this :
Also read the help page of ave, that will help you understand what the code is doing exactly.