library(ggplot2)
NEI <- readRDS("summarySCC_PM25.rds")
SCC <- readRDS("Source_Classification_Code.rds")
vehicles_SCC <- SCC[grep("Veh", SCC$SCC.Level.Two), ]$SCC
subset <- NEI[NEI$SCC %in% vehicles_SCC
& NEI$fips %in% c('24510', '06037'),]
subset$fips <- factor(subset$fips, c('24510', '06037'),
labels=c('Baltimore', 'Los Angeles'))
agg_data <- aggregate(Emissions ~ fips + year, subset, FUN=mean)
mainplot <- ggplot(agg_data, aes(x=year, y=Emissions, color=fips)) + geom_line()
mainplot <- mainplot + ggtitle(bquote(PM[2.5] : " vehicle emissions by year by city"))
print(mainplot)