Social Media Research

02 R Data Analysis


Question

What is the function of aggregate? Write down the code to aggregate the mean price of products from a list, where products are given with detailed brand and price.


Answer

Aggregate "aggregates" the inputted data by applying a special function (FUN = (...)), e. g. the mean value. The function is applied to each column of the sub-data.frame defined by the input parameter: aggregate (Object, by=list(Input Parameter), FUN=Function); e. g. aggregate(products$price, by=list(products$name), FUN=mean)




Comments