Advertisement
friedmusic

A12

Feb 26th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.78 KB | None | 0 0
  1. ---
  2. title: "A12 by Noah Perry & Andrew Hall"
  3. output:
  4.   pdf_document: default
  5.   html_notebook: default
  6. ---
  7. You have access to a dataset <http://www.richardtwatson.com/data/LiOnBattery.csv> containing details of projected prices of Li-On batteries. Assume GM pays $300 per kilowatt-hour for the cells in the battery pack of the 2017 Chevrolet Bolt EV, which has a capacity of 60kWh and sells for $37,500. In other words, batteries are about half the current consumer cost of the car (StorageCost*60 = $18,000), and the other components cost the consumer about $19,500.
  8.  
  9. Use ggplot2 to create
  10. a point graph showing the projected cost of LiOn batteries.
  11. a line graph showing the projected cost of batteries for a Chevy Bolt
  12. a bar graph of the projected cost of a Chevy Bolt.  
  13. Use googleVis to create one or more appropriate counterparts to those of ggplot2.
  14.  
  15.  
  16. ```{r Cleaning}
  17. library(tidyverse)
  18. library(googleVis)
  19. da <- read_csv("http://www.richardtwatson.com/data/LiOnBattery.csv")
  20.  
  21.   da <- da %>% rename(StorageCost = `Projected cost of Li-On Battery Storage ($/kW)`) %>%
  22.     mutate(Year = as.integer(Year)) %>% mutate(StorageCost = as.integer(StorageCost)) %>%
  23.     mutate(BoltStorageCost=as.integer(StorageCost*60)) %>% mutate(BoltTotalCost=as.integer(StorageCost*60+19500))
  24.   da
  25. ```
  26.  
  27. ```{r plot1}
  28.   ggplot(da, aes(Year, StorageCost, label=Year)) + geom_point(color='red') + xlab('Year') +
  29.     ylab('Projected cost of Li-On Battery Storage ($/kW)')  + ylim(90, 200)
  30. ```
  31.  
  32. ```{r plot2}
  33.   ggplot(da, aes(Year, BoltStorageCost, label=Year)) + geom_point(color='red') + xlab('Year') +
  34.     ylab('Projected cost of Li-On Battery Storage for 2017 Chevrolet Bolt EV ($)') + ylim(5000, 10000)
  35. ```
  36.  
  37. ```{r plot3}
  38.  Bar <- gvisBarChart(da,xvar="Year", yvar="BoltTotalCost")
  39.  print(Bar)
  40. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement