Skip to content

Commit

Permalink
Merge branch 'wip' after adding notebooks and Rmd
Browse files Browse the repository at this point in the history
 Conflicts:
	Graphs.R
	Graphs.Rmd
	ReadMe.Rmd
	ReadMe.html
	ReadMe.md
	data/Covid19ECDC_days.csv
	data/Covid19JHH_days.csv
	definitions.R
	deprecated.R
	loadData.R
	output.Rmd
	requirements.R
	wip.R

 On branch master
 Your branch is up to date with 'origin/master'.

 All conflicts fixed but you are still merging.

 Changes to be committed:
	modified:   Graphs.R
	modified:   Graphs.Rmd
	new file:   Graphs.ipynb
	new file:   Graphs.md
	modified:   ReadMe.Rmd
	new file:   ReadMe.html
	modified:   ReadMe.md
	modified:   data/Covid19ECDC_days.csv
	modified:   data/Covid19JHH_days.csv
	modified:   definitions.R
	new file:   deprecated.R
	deleted:    gifit.R
	new file:   gifit.Rmd
	new file:   graphit.R
	modified:   loadData.R
	modified:   output.Rmd
	new file:   output.ipynb
	new file:   output.tex
	modified:   requirements.R
	modified:   unittests.R
	modified:   wip.R
  • Loading branch information
vinnief committed Sep 10, 2020
2 parents 141359b + bada0a4 commit 91e3e34
Show file tree
Hide file tree
Showing 21 changed files with 125,863 additions and 517 deletions.
16 changes: 5 additions & 11 deletions Graphs.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,20 @@
#for publication
rm(list = setdiff(ls(), c('ECDC0', 'JHH0', 'JHH', 'ECDC', 'JHHRegios', 'ECDCRegios','testing')))
options(warn = 0)
source("loadData.R") #also loads the requirements and the definitions
if (!exists('JHH')) source('loadData.R') else
if (max(JHH$Date) < Sys.Date() - 1) {source('loadData.R')
}else if (!exists('graphit')) source('definitions.R')

#also loads the requirements and the definitions

#make all graphs
tim = Sys.time()
#curGraph(lpdf = ECDC, regions = ECDCRegios, graphlist = myGraphNrs, ordre = 'GR')
walkThrough(lpdf = ECDC, regions = ECDCRegios, graphlist = myGraphNrs, myFolderDate = 'current', ordre = 'RG')
reportDiffTime('ECDC graphs',tim, units = 'mins')

tim = Sys.time()
#curGraph( lpdf = JHH, regions = JHHRegios, graphlist = myGraphNrs, ordre = 'RG')
walkThrough( lpdf = JHH, regions = JHHRegios, graphlist = myGraphNrs, myFolderDate = 'current', ordre = 'RG')
reportDiffTime('JHH graphs',tim,units = 'mins')



#do a month
walkThrough(lpdf = JHH, regions = JHHRegios, graphlist = myGraphNrs, from = "2020-01-01", to = '2020-01-31', myFolderDate = 'January', ordre = 'RG')
walkThrough(lpdf = JHH, regions = JHHRegios, graphlist = myGraphNrs, from = "2020-04-01", to = '2020-04-30', myFolderDate = 'April', ordre = 'RG')
walkThrough(lpdf = JHH, regions = JHHRegios, graphlist = myGraphNrs, from = "2020-06-01", to = '2020-06-30', myFolderDate = 'June', ordre = 'RG')


writeWithCounters(ECDC,name = "Covid19ECDC")
writeWithCounters(JHH,name = "Covid19JHH")
76 changes: 45 additions & 31 deletions Graphs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,66 @@ author: "VF"
date: "9 July 2020"
output: html_document
---
##Graphs

Run loadData.R or output.Rmd first to load the latest Data and the definitions.
Please make sure myPlotPath is correct!

```{r, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
if (!exists('graphit')) source('definitions.R')
if (!exists('JHH')) source('loadData.R')
switch(get_os(),
windows = {print("I run MS Windows.");myPlotPath <- "G:/My Drive/Covid19_plots"},
linux = {print("I'm a penguin."); myPlotPath <- "~/Covid19_plots"},
osx = {print("I'm a Mac.");myPlotPath <- "~/Covid19_plots"},
... = {print('not recognized OS');myPlotPath <- "~/Covid19_plots"})
```{r init, include=FALSE}
#knitrr::opts_chunk$set(echo = TRUE)
if (!dir.exists(myPlotPath %//% 'data')) dir.create(myPlotPath %//% 'data', recursive = TRUE)
if (!exists('JHH')) source('loadData.R') else
if (max(JHH$Date) < Sys.Date() - 1) {source('loadData.R')
} else source('definitions.R')
save.image(".RData") #D:/gits/Covid19/
#switch(get_os(),
# windows = {print("I run MS Windows.");
# myPlotPath <- "G:/My Drive/Covid19_plots"},
# linux = {print("I'm a penguin."); myPlotPath <- "~/Covid19_plots"},
# osx = {print("I'm a Mac.");myPlotPath <- "~/Covid19_plots"},
# ... = {print('not recognized OS');myPlotPath <- "~/Covid19_plots"})
if (!dir.exists(myPlotPath %//% 'data')) dir.create(myPlotPath %//% 'data', recursive = TRUE)
writeWithCounters(ECDC,name = "Covid19ECDC")
writeWithCounters(JHH,name = "Covid19JHH")
```

Graph and save lots of graphs on all regions present, paginated by size of the Covid impact (total confirmed cases), and on each page, territory graphs are sorted by decreasing value of the first graphed variable on the latest date in that territory.


```{r , echo = FALSE}
```{r graphs walkthrough, echo=FALSE}
print("results of" % % Sys.Date())
verbose = 0
tim = Sys.time()
#curGraph(lpdf = ECDC, regions = ECDCRegios, graphlist = myGraphNrs, ordre = 'GR')
walkThrough(lpdf = ECDC, regions = ECDCRegios, graphlist = myGraphNrs, myFolderDate = 'current', ordre = 'RG')
walkThrough(lpdf = ECDC, regions = ECDCRegios, graphlist = myGraphNrs, myFolderDate = 'current', ordre = 'GR')
reportDiffTime('ECDC graphs',tim, units = 'mins')
tim = Sys.time()
#curGraph( lpdf = JHH, regions = JHHRegios, graphlist = myGraphNrs, ordre = 'RG')
walkThrough( lpdf = JHH, regions = JHHRegios, graphlist = myGraphNrs, myFolderDate = 'current', ordre = 'RG')
walkThrough( lpdf = JHH, regions = JHHRegios, graphlist = myGraphNrs, myFolderDate = 'current', ordre = 'GR')
reportDiffTime('JHH graphs',tim,units = 'mins')
```
```

Development one month at a time
```{r}
walkThrough(lpdf = JHH, regions = JHHRegios, graphlist = myGraphNrs, from = "2020-01-01", to = '2020-01-31', myFolderDate = 'January', ordre = 'RG')
walkThrough(lpdf = JHH, regions = JHHRegios, graphlist = myGraphNrs, from = "2020-04-01", to = '2020-04-30', myFolderDate = 'April', ordre = 'RG')
walkThrough(lpdf = JHH, regions = JHHRegios, graphlist = myGraphNrs, from = "2020-06-01", to = '2020-06-30', myFolderDate = 'June', ordre = 'RG')
```{r one month, include=FALSE, eval=FALSE}
if ( mday(Sys.Date() ) <= 03) {#uses lubridate
walkThrough(lpdf = JHH, regions = JHHRegios, graphlist = myGraphNrs,
from = floor_date(Sys.Date() %m-% months(1), 'month'),
to = ceiling_date(Sys.Date() %m-% months(1), 'month')-1,
myFolderDate = year(Sys.Date() %m-% months(1)) %-% sprintf("%02d", month(Sys.Date() %m-% months(1))),
ordre = 'RG')
}
```

do all months up to today
```{r}
Do all months up to today
```{r all months, include=FALSE, eval=FALSE}
verbose = 1
makeHistoryGraphs(JHH, regions = JHHRegios, fromDates = seq(as.Date('2020-01-01'),Sys.Date(), by = '1 month'), ordre = 'GR')
makeHistoryGraphs(ECDC, regions = ECDCRegios, fromDates = seq(as.Date('2020-01-01'),Sys.Date(), by = '1 month'))
```
A more convoluted way:
```{r}
A more convoluted way, just for the record:
```{r all months convoluted, include=FALSE, eval=FALSE}
startDate = "2020-01-01"
fromDates <- as.character(seq(as.Date(startDate), length = 12, by = "1 month"))
toDates <- as.character(seq(as.Date(fromDates[2]), length = 12, by = "1 month") - 1)
Expand All @@ -66,13 +77,14 @@ makeHistoryGraphs(JHH,JHHRegios, graphlist = myGraphNrs,
```
This do once in a while, to do all the non-numbererd graphs.

```{r}
```{r byDate once a week}
if ( weekdays( Sys.Date() , abbreviate = FALSE) == "Friday")
walkThrough(ECDC, ECDCRegios, graphlist = myGraphListbyDate, myFoldetDate = 'weekly')
walkThrough(JHH, JHHRegios[1:10], graphlist = myGraphListbyDate,
myFolderDate = 'weekly')
```

Simulate how the non-social distancing situation would have turned out: deaths, recovered, and confirmed
```{r}
```{r sims, include=FALSE, eval=FALSE}
graphDddp_fyl(JHH,regios$Vincent,savename = "deaths missed")
walkThrough(JHH, regions = JHHRegios,graphlist = 'graphDccprr_fyl')
Expand All @@ -81,10 +93,12 @@ walkThrough(ECDC , ECDCRegios,ext = '_endsim',graphlist = c('graphDccprr_fiyl',
```
## R Markdown
## R Markdown and Jupyter Notebook: sync with Jupytext.

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 <http://rmarkdown.rstudio.com>.
This is an R Markdown document, linked to the same document as Jupyter notebook, using Jupytext. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

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:

Note that the `{r, echo = FALSE}` parameter can be added to the code chunk to prevent printing of the R code that generated the plot.
Note that the `{r, echo = FALSE}` parameter can be added to the code chunk to prevent printing of the R code that generated the plot. And Include = false prevents automatic execution of the block.

Second, note that for git, the ipynb files containing output are much heavier than the Rmd files which contain the inputs only, according to Jupytext faq (https://jupytext.readthedocs.io/en/latest/faq.html). I commit both just to be sure at this moment.
Loading

0 comments on commit 91e3e34

Please sign in to comment.