There are two methods that is collapsing data by using one or more BY variable and other is aggregate() function in which BY variable should be in list.