I have a dataframe DF with 4 columns (variables) A, B, C, and D, and want to create a new dataframe DF2 by keeping B and C in DF but counting the frequency of D while collapsing A. I tried by(DF$D, list(DF$B, DF$C), FUN=summary) but this is not exactly what I want. What is a good way to do it? Thanks, Gang