I need to return the n most frequent occurrences of a string, using a multiple row data frame as the input. All the values are in the same column called \"MissingDates\"
It seems like you need something like:
Function
freqfunc <- function(x, n){ tail(sort(table(unlist(strsplit(as.character(x), ", ")))), n) }
Testing on your data set
freqfunc(gaps$MissingDates, 5) # Five most frequent dates ## 1996-12-26 1997-12-26 1998-01-02 1999-12-31 2001-09-12 ## 4 4 4 4 4