I have a data that looks like this:
and I would like to summarise the data into multi-level rows and columns and I would like to make it look like this
I was successful in creating multi-level rows but could not put the price_flag in columns. I used the below mentioned code to do that
aggregate(data$year, by = list(data$class, data$year), FUN = length)
Help would be deeply appreciated.