[R] Data aggregation
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] Importing data from a text file with no separator
I have row data in a text file, where each row consists of 22 numerical characters. Each row consists of three different column but there is no separator. Specifically, the first two characters of the raw represent the first column of data, the subsequent 8 characters represent the second column of data and the last 12 characters represent the third column of data. An example follows: row data: 10030614911608 The first two characters, "10", is the column "Regime"; the subsequent 8 characters, "03061490", is the column "Industry", and the last 12 characters, "00011608", is the column dollar value. How do I import the column data into R without having any separator in the text file? Thanks for your help, 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.