stations %>% mutate(Filename=paste0('tp ',Station,'.png')) -> files2 for (i in 1:nrow(files2)) with(files2, { png(Filename[i],width=400,height=300) local_trendplot(Station[i],rain2) dev.off()} ) files2 %>% mutate(Popup=paste0('<img src="',Filename,'">')) -> files2 rain %>% group_by(Station) %>% summarise(mrain=mean(Rainfall)) %>% left_join(files2) %>% select(Long,Lat,mrain,Popup) -> station_means2 color_fun <- colorNumeric('YlGnBu',station_means2$mrain) leaflet(data=station_means2,height=430,width=600) %>% addProviderTiles('CartoDB.Positron') %>% setView(-8,53.5,6) %>% addCircleMarkers(fillColor=~color_fun(mrain),weight=0,fillOpacity = 0.85,popup=~Popup) %>% addLegend(pal=color_fun,values=station_means$mrain,title="Rainfall",position='bottomleft')
The Holy Grail
Full details of any results reported and the methods and data used to obtain them should be made available, so that others following the same methods can obtain identical results.
Rmarkdown is open source software for dynamic report generation with R, enabling integration of R code into PDF, HTML, and MS Word documents. Effectively it embeds R code into documents.
(p. 104 of the Russell Report)
---
title: "RMarkdown"
author: "Chris Brunsdon"
date: "17 November 2015"
output: html_document
---
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax
for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see .
When you click the **Knit** button a document will be generated that includes
both content as well as the output of any embedded R code chunks within the document.
You can embed an R code chunk like this:
```{r hello}
print('hello world!')
```
.Rmd
# Subject
- Highest Level Header
## Less important subject
- Next level down### Even less important subject
- Next level down#### Trivia
- Lowest level
- Include an image in document<http://rmarkdown.rstudio.com>
- Include clickable link to URLEvaluate but don’t echo in the document:
```{r hello,echo=FALSE}
print('hello world!')
```
Graphics are directly embedded - just include the plotting code
```{r randomplot,echo=FALSE}
x <- seq(-1,1,length=21)
y <- x*x + rnorm(21)/10
plot(x,y)
```
So are dygraph
commands
```{r rain_dygraph,echo=FALSE}
rain_ts %>% dygraph
```
and leaflet
and tmap
commands
```{r station_map,echo=FALSE}
tm_shape(stations) + tm_bubbles()
```
#reproducible
First set up two time series
library(dygraphs) rain %>% group_by(Year,Month) %>% filter(Station=="Dublin Airport") %>% summarise(Rainfall=sum(Rainfall)) %>% ungroup %>% transmute(Rainfall) %>% ts(start=c(1850,1),freq=12) -> dub_ts rain %>% group_by(Year,Month) %>% filter(Station=="Belfast") %>% summarise(Rainfall=sum(Rainfall)) %>% ungroup %>% transmute(Rainfall) %>% ts(start=c(1850,1),freq=12) -> bel_ts
Then use group
to link multiple embedded dygraphs
dub_ts %>% dygraph(width=800,height=130,group="dub_belf",main="Dublin")
bel_ts %>% dygraph(width=800,height=170,group="dub_belf",main="Belfast") %>% dyRangeSelector
Modify the header
---
title: "My Life as a Hell's Angel"
author: "Daniel O'Donell"
date: ""
output:
ioslides_presentation:
widescreen: true
---
Bullet points
- Level 1
- Level 2
- Still level 2
- Back to level 1 *italic*
- Still level 1 **bold**
publish
option in the top right of the windowpublish
gives your article a web site
Create an Rpubs blog showing how to create a monthplot
of the mean rainfall data for Ireland on a month-by-month basis from January 1970 to December 1979, and briefly describing the patterns in the plot.