Skip to content
Prev 361889 / 398506 Next

Data aggregation

Hello,

Try the following.

dat <- read.csv(text = "
Regime, Industry, Cost
10, 01, 370
11, 01, 400
10, 02, 200
10, 01, 500
11, 02, 60
10, 02, 30
")

dat

res <- aggregate(Cost ~ Industry + Regime, data = dat, sum)

res <- res[order(res$Industry), ]
res

And see the help page ?aggregate

Hope this helps,

Rui Barradas


Quoting Paolo Letizia <paolo.letizia at gmail.com>: