?tapply You should have encountered this already in most basic R tutorials. Have you gone through any? If not, you should. In particular,you need to learn about R's basic data structures (e.g. data frames).
Alternatively, the dplyr package has many elegant tools for this sort of thing. You might do well to learn it instead or in addition to the *apply type operations of base R. Finally, I should ask: is this homework? This list tries to implement a no homework policy. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Jun 20, 2016 at 2:34 PM, Paolo Letizia <paolo.leti...@gmail.com> wrote: > Dear All: > I have a data frame with 3 columns: "Regime", "Industry", and "Cost". > I want to sum the value of "Cost" for each industry and "Regime". > Example: > > The data frame is: > Regime, Industry, Cost > 10, 01, 370 > 11, 01, 400 > 10, 02, 200 > 10, 01, 500 > 11, 02, 60 > 10, 02, 30 > > I want the following output: > 01, 10, 870 > 01, 11, 400 > 02, 10, 230 > 02, 11, 600 > > Can you please help me on this? Paolo > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.