Advertisement
Guest User

A23

a guest
Apr 25th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. ---
  2. title: "A23 By Andrew Hall and Noah Perry"
  3. output: html_notebook
  4. ---
  5.  
  6. A csv file <http://www.richardtwatson.com/data/electricityprices.csv> contains hourly electricity prices for a U.S. state. Do a time series analysis of the average daily price. Use dygraph to produce a plot. What are your conclusions?
  7.  
  8. ```{r}
  9. library(tidyverse)
  10. library(dygraphs)
  11. library(xts)
  12.  
  13. url<-'http://www.richardtwatson.com/data/electricityprices.csv'
  14. t<-read_csv(url)
  15. t
  16.  
  17. #group to average cost per day
  18. t$Julian<-as.integer(julian(t$timestamp))
  19. t2<-t%>%group_by(Julian)%>%summarise(mean(cost))
  20. t2
  21. #convert to timeseries object
  22. xts<-xts(t2$`mean(cost)`, order.by = as.Date(t2$Julian))
  23.  
  24. #dygraph
  25. dygraph(xts)
  26.  
  27.  
  28. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement