Title: | Coronavirus ('Rona') Data Exploration |
---|---|
Description: | Manipulate and view coronavirus data and other societally relevant data at a basic level. |
Authors: | Jo van Schalkwyk [aut, cre] |
Maintainer: | Jo van Schalkwyk <[email protected]> |
License: | GPL-3 |
Version: | 0.3.0 |
Built: | 2024-11-09 04:38:45 UTC |
Source: | https://github.com/cran/corona |
Used to introduce power laws.
allo
allo
A data frame with 455 rows.
Metabolic rate
https://royalsocietypublishing.org/doi/suppl/10.1098/rsbl.2005.0378
These are a bit unusual in that each country has a column.
citymap
citymap
A data frame with 108 rows.
https://citymapper.com/cmi/about
Country data from Our World In Data.
cntry
cntry
A data frame with 17,013 rows (current)
ISO 3-letter country code
Text name of country
Alias country name, shorter
Start of 'summer' viral respiratory low
End of respiratory low. Sketchy at present.
https://github.com/owid/covid-19-data/tree/master/public/data and https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4847850/
Try ?corona for help. For most functions, saying pdf=TRUE will write a PDF to images/. If you wish to print to PDF, you need to setwd() to a directory that contains an images/ directory that can be written to, or this will fail. Individual examples are also available. Try e.g. ?corona_rabbits or ?corona_country The results of corona_life() will depend on how your system handles animated GIF files.
corona()
corona()
corona_rabbits ( ) corona_monty ( ) corona_country ('France') corona_vienna ( ) corona_totals ( ) country_dead ( ) corona_converge ( ) corona_metabolism ( ) corona_citymap ( ) corona_dowjones ( )
corona_rabbits ( ) corona_monty ( ) corona_country ('France') corona_vienna ( ) corona_totals ( ) country_dead ( ) corona_converge ( ) corona_metabolism ( ) corona_citymap ( ) corona_dowjones ( )
For the book 'Rona' (printing to PDF) work through and generate PDFs for all examples.
corona_all()
corona_all()
Requires ggplot2, plyr and the data frames lock, owid, citymap. Multiple, select frames are plotted.
corona_citymap(pdf = FALSE, FewCities = NULL, cols = 4)
corona_citymap(pdf = FALSE, FewCities = NULL, cols = 4)
pdf |
= TRUE writes to PDF, default FALSE |
FewCities |
a c() list of city names from the city options. Default is all. |
cols |
Number of columns in output, default is 4 |
corona_citymap(cols=4);
corona_citymap(cols=4);
Build a normal or log-normal distribution from simple components. Large numbers e.g. n=1e6 will take some time to run.
corona_converge( n = 1e+05, method = "add", runs = 7, pdf = FALSE, xscale = 1, bins = 64, log = FALSE )
corona_converge( n = 1e+05, method = "add", runs = 7, pdf = FALSE, xscale = 1, bins = 64, log = FALSE )
n |
is the number of samples |
method |
is either 'multiply' or 'add' |
runs |
number of iterations (default 7) |
pdf |
defaults to FALSE |
xscale |
a scaling factor, can use values < 1.0 to magnify (x) e.g. 0.4 |
bins |
defaults to 64 |
log |
take logarithm of values (for 'multiply') |
corona_converge( n=10000, method='multiply', xscale=0.4, bins=128, runs=5 )
corona_converge( n=10000, method='multiply', xscale=0.4, bins=128, runs=5 )
The daily case rate is also shown as a smoothed curve. The smoothed death incidence is MULTIPLIED x5 to highlight its relationship to the incidence curve. See grown-up documentation (LyX)
corona_country(country, pdf = FALSE, smooth = TRUE, deaths = TRUE)
corona_country(country, pdf = FALSE, smooth = TRUE, deaths = TRUE)
country |
: no default |
pdf |
: defaults to FALSE. If TRUE, writes to country_name_new.pdf i.e. 'new.pdf' is appended to formal country name. If the country name contains spaces ' ' they are changed to underscores '' |
smooth |
: default TRUE show smoothed (red) curve |
deaths |
: default TRUE show deaths |
corona_country('United States'); corona_country('Taiwan');
corona_country('United States'); corona_country('Taiwan');
Assumes the existence of the data frame djia, part of corona data.
corona_dowjones(pdf = FALSE)
corona_dowjones(pdf = FALSE)
pdf |
: will not print to PDF |
corona_dowjones ( )
corona_dowjones ( )
The canvas (arena) wraps around vertically and horizontally! Execution will take some time. Results will be viewed differently depending on your system's default viewer for animated GIF files.
corona_life( pattern = "soup", side = 50, steps = 100, density = 0.3, filename = NULL, wrap = TRUE, fps = 20, pause = 10 )
corona_life( pattern = "soup", side = 50, steps = 100, density = 0.3, filename = NULL, wrap = TRUE, fps = 20, pause = 10 )
pattern |
Defaults to 'soup' but there are many other well-known options: blinker ttetromino rpentomino toad beehive beacon clock pulsar pentadecathlon galaxy spaceship glidergun piheptomino switchengine conway acorn rabbits boring static patterns: block snake eater |
side |
The number of elements on the area's side (width or height) |
steps |
The number of frames |
density |
0.0–1 The density of the initial, random items ('soup') |
filename |
writes to this file name e.g. foo.gif (NULL for current GIF device) |
wrap |
Wrap around |
fps |
Frames per second |
pause |
Initial pause |
## Not run: corona_life( filename='animation.gif', side=50, steps=500, density=0.2 ) corona_life( side=100, steps=1000, pattern='rpentomino', wrap=FALSE ) corona_life( side=30, steps=120, pattern='spaceship' ) corona_life( side=100, steps=400, pattern='switchengine' ) corona_life( side=20, steps=30, pattern='clock' ) corona_life( side=20, steps=30, pattern='galaxy' ) corona_life( side=100, steps=200, pattern='glidergun' ) corona_life( side=45, steps=130, pattern='conway', fps=8, pause=40) ## End(Not run)
## Not run: corona_life( filename='animation.gif', side=50, steps=500, density=0.2 ) corona_life( side=100, steps=1000, pattern='rpentomino', wrap=FALSE ) corona_life( side=30, steps=120, pattern='spaceship' ) corona_life( side=100, steps=400, pattern='switchengine' ) corona_life( side=20, steps=30, pattern='clock' ) corona_life( side=20, steps=30, pattern='galaxy' ) corona_life( side=100, steps=200, pattern='glidergun' ) corona_life( side=45, steps=130, pattern='conway', fps=8, pause=40) ## End(Not run)
By default limited to countries with population > 4M, and over 200 cases. This may take over 5s to run, depending on your hardware.
corona_lockdown( pdf = FALSE, minpeople = 4e+06, mincases = 200, cols = 7, striptextsize = 10, textsize = 10, legendx = 0.94, legendy = 0.02 )
corona_lockdown( pdf = FALSE, minpeople = 4e+06, mincases = 200, cols = 7, striptextsize = 10, textsize = 10, legendx = 0.94, legendy = 0.02 )
pdf |
print to PDF |
minpeople |
Minimum population for the country |
mincases |
Minimum number of COVID-19 cases |
cols |
Number of columns to display, default = 7 |
striptextsize |
size of text in country names |
textsize |
Size of text header |
legendx |
X position of legend |
legendy |
Y position of legend |
## Not run: corona_lockdown( cols=14 ) ## End(Not run)
## Not run: corona_lockdown( cols=14 ) ## End(Not run)
Log-log plot of mammalian weights (grams) against metabolic rates. The PDF file is allometry.pdf.
corona_metabolism(pdf = FALSE, base = 10)
corona_metabolism(pdf = FALSE, base = 10)
pdf |
will not print to PDF |
base |
base for logarithms, default 10 |
corona_metabolism ( )
corona_metabolism ( )
A Monte Carlo simulation of the Monty Hall problem
corona_monty(runs = 100)
corona_monty(runs = 100)
runs |
specifies the number of parallel simulations, default=100. |
corona_monty ( runs=10000 )
corona_monty ( runs=10000 )
For finer details, see the LyX/PDF documentation.
corona_rabbits(topyear = 6, pdf = FALSE)
corona_rabbits(topyear = 6, pdf = FALSE)
topyear |
is last year, defaults to 6 |
pdf |
Will not print to PDF if FALSE (the default) |
corona_rabbits( topyear=10)
corona_rabbits( topyear=10)
Defaults to Italy, as this was our demonstration. Add a linear regression by specifying smooth=TRUE.
corona_totals( country = "Italy", daystart = 60, dayend = 76, pdf = FALSE, log = FALSE, smooth = FALSE, prefix = "" )
corona_totals( country = "Italy", daystart = 60, dayend = 76, pdf = FALSE, log = FALSE, smooth = FALSE, prefix = "" )
country |
Text name of country (in owid frame) |
daystart |
first day |
dayend |
last day to plot |
pdf |
TRUE will print value |
log |
TRUE will take base 10 logarithm of y-axis values |
smooth |
TRUE will try to fit linear model (use with logarithm) |
prefix |
defaults to ”; a text value will be prefixed to PDF name after country_ name. |
corona_totals( country='Italy', daystart=60, dayend=76, log=TRUE, smooth=TRUE ) corona_totals(country='United Kingdom', log=TRUE, smooth=TRUE)
corona_totals( country='Italy', daystart=60, dayend=76, log=TRUE, smooth=TRUE ) corona_totals(country='United Kingdom', log=TRUE, smooth=TRUE)
Just plot the lines.
corona_trends(pdf = FALSE)
corona_trends(pdf = FALSE)
pdf |
default FALSE will not print the PDF file |
corona_trends ( )
corona_trends ( )
First simply 'plots the dots'; subsequently draws a run chart with a transition at the point where he instituted hand-washing.
corona_vienna(pdf = FALSE)
corona_vienna(pdf = FALSE)
pdf |
default FALSE will not print the two PDF files: semmelweis_plot.pdf semmelweis_run.pdf |
corona_vienna ( )
corona_vienna ( )
Assumes the existence of the data frame stmf containing relevant iso_codes for countries. The unusual codes GBRTENW and GBR_SCO represent England+Wales and Scotland. You can obtain a list of countries by country_dead('?'), forcing a diagnostic error!
country_dead(country = "England+Wales", pdf = FALSE, save = FALSE)
country_dead(country = "England+Wales", pdf = FALSE, save = FALSE)
country |
Country name |
pdf |
default FALSE will not print to PDF |
save |
Do we save the data as a CSV |
The columns in the frame stmf are just 'iso_code', 'Year', 'Week', and 'Deaths'.
Draws three graphs:
Raw data with a linear regression line, over n years;
Data with secular adjustment;
Data adjusted for a 'summer baseline' using the "other n years of data" after secular adjustment.
country_dead( 'New Zealand' )
country_dead( 'New Zealand' )
Historical Dow Jones Industrial Average prices.
djia
djia
A data frame with 110 rows (current)
Date of transaction—excludes weekends etc
Opening average
Maximum over the day
Minimum
Closing price
https://www.wsj.com/market-data/quotes/index/DJIA/historical-prices
Google trends search for 'coronavirus'.
gt
gt
A data frame with 155 rows (current)
Date in format YYYY-MM-DD
Coronavirus 'interest' as percentage of maximum count
https://trends.google.com/trends/
This specifies initial conditions, using a clumsy storage format as below.
life
life
A data frame with 213 rows.
x co-ordinate of an active cell
y co-ordinate
A name like 'blinker' — will be common to several rows, specifying a Game of Life pattern
(internal generation)
Approximate dates of full lockdown in various countries.
lock
lock
A data frame with 110 rows (current)
Country
Date of lockdown YYYY-MM-DD
Text description: national | partial | advice | empty(none)
Various data sources.
Wide-ranging data from Our World In Data. I only use a tiny part.
owid
owid
A data frame with 17,013 rows (current)
ISO 3-letter country code
Date for this row of data
total cases to date
new cases
eponymous
Recorded tests in toto
Eponymous
How severe the lockdown was
https://github.com/owid/covid-19-data/tree/master/public/data
Deaths, by week, for various countries.
stmf
stmf
A data frame with 22678 rows.
Normally a 3-character country code e.g. NZL, AUT. England+Wales=GBRTENW, Scotland=GBR_SCO
YYYY
Week within that year, 1=1st
Number of deaths in that week
https://www.ons.gov.uk/peoplepopulationandcommunity/birthsdeathsandmarriages/deaths/datasets/weeklyprovisionalfiguresondeathsregisteredinenglandandwales https://www.stats.govt.nz/experimental/covid-19-data-portal https://www.scb.se/en/finding-statistics/statistics-by-subject-area/population/population-composition/population-statistics/#_Tablesandgraphs and also (registration now required) https://www.mortality.org/
Semmelweis' data on Deaths of parturients in Vienna
vienna
vienna
A data frame with 98 rows
Date of the start of each month YYYY-MM-01
Number of births during that month
Number of maternal deaths during that month
https://en.wikipedia.org/wiki/Historical_mortality_rates_of_puerperal_fever