Hi All
I have a very large Excel table with data in two columns as follows. My goal is to reduce the number of entries by grouping the results. For example, I want to sum the kg of CO2 produced in the use of "Heat". I am only interested in the values where "Heat" is the first word in the string. I expect to have 1000+300=1300 for Heat. I am unsure how to go about this. Below are my steps so far.
Afterwards, I plan to create a bar chart showing how much CO2 each process grouping creates.
I have to do this for about 30 Excel Tables and produce 30 bar charts. Maybe there is a way to reduce the workload?
Process & Mass of CO2
Heat & 1000
Electricity_and_heat & 2000
Electricity & 1000
Heat_China & 300
China_heat & 1000
##Select rows containing "Heat" - but this does not mean that it is at the start of the string
library(readxl)
Book1 <- read_excel("Book1.xlsx")
View(Book1)
data2 <- Book1[str_detect(Book1$Proces, "Heat"), ]
data2
Please help. Thanks in advance!