I have a very large data frame and want to create some simple tables. The problem with a dataset so big, is that I have a lot of values that only occur a few times.
What I want to achieve is to create a table for each of the qualitative variables, and have the least occuring values in each variable appear under a grouped tag. The first part is easy enough:
sapply(dat[!sapply(dat, is.numeric)], table)
but how do I group the values that are present less than x times and also put them in the table in a 'Others' tag? Is there any table function that has a parameter that does this? Or am I going to have to manually manipulate the data.frame
, find all the lest occuring values and change the value for them to 'Other'?