Create a time series graph for the total rainfall for the period 1901-2016.

Assam%>%  group_by(Year,Month) %>% 
  summarise(Rainfall=sum(Rainfall)) %>% ungroup %>% transmute(Rainfall) %>% 
  ts(start=c(1901,1),freq=12) -> rain_ts
rain_ts %>% window(c(1901,1),c(1902,12))
##        Jan   Feb   Mar   Apr   May   Jun   Jul   Aug   Sep   Oct   Nov   Dec
## 1901 223.0 464.1   1.2  19.5  27.1 430.6 524.9  30.6 207.0 115.6 163.7 291.4
## 1902 350.0 536.0   1.3  10.2   9.3 510.8 620.7 105.6 262.1   7.8  97.0 441.3

The above code would translate into: Take the rain data then group it by year and month then summarize the sum of rainfall, then ungroup (which undoes the group_by, and this is necessary for the transmute function ), then transmute the rainfall (which modifies values in the data frame and drops unreferenced variables), and create a monthly time series which has January 1901 as the starting date. A new data frame is created, names rain_ts, which will be used in subsequent code.

Then create a dygraph with an interactive window of the total rainfall for the period 1901-2016. The command dyRangeSelector creates a range selector at the bottom of the graph which allows you zoom in on any time frame of your choice within the period 1901-2016 to evaluate rainfall patterns and/or amounts.

Graph

rain_ts %>% dygraph(width=800,height=300,main="Assam And Meghalaya Rainfall 1901 to 2016") %>% dyRangeSelector

Adding an interactive rolling mean

The dyRoller control was then used to apply a rolling mean to each of these dygraphs. A rollPeriod of 240 months was selected, meaning that a 20 year moving mean was calculated. This allows the long-term trend in the monthly rainfall for the station(Assam and Meghalaya) to be more clearly analysed.The peroid of months can be changed according the need of the user

rain_ts %>% dygraph(width=800,height=400,main="Assam And Meghalaya Rainfall 1901 to 2016") %>% dyRoller(rollPeriod= 240)