Skip to content

Commit

Permalink
adding geo locns grouping by continent capbilites
Browse files Browse the repository at this point in the history
  • Loading branch information
mponce0 committed Jul 11, 2020
1 parent ada2622 commit 501d00d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: covid19.analytics
Type: Package
Title: Load and Analyze Live Data from the CoViD-19 Pandemic
Version: 1.1.1
Date: 2020-07-02
Date: 2020-07-11
Author: Marcelo Ponce [aut, cre]
Maintainer: Marcelo Ponce <[email protected]>
Description: Load and analyze updated time series worldwide data of reported cases for the Novel CoronaVirus Disease (CoViD-19) from the Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE) data repository <https://github.com/CSSEGISandData/COVID-19>. The datasets are available in two main modalities, as a time series sequences and aggregated for the last day with greater spatial resolution. Several analysis, visualization and modelling functions are available in the package that will allow the user to compute and visualize total number of cases, total number of changes and growth rate globally or for an specific geographical location, while at the same time generating models using these trends; generate interactive visualizations and generate Susceptible-Infected-Recovered (SIR) model for the disease spread.
Expand Down
5 changes: 4 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
May 2020: XXXX _ ver 1.1.1

Jul 2020: Several new features and bugs fixes _ ver 1.1.1
- added new geographical categories to select data per continents, implemented via geographicalRegions() fn
- added tests cases
- geneate.SIR.model()/plt.SIR.model(): added plotting of time derivatives and "force of infection"
- covid19.Toronto.data(): updated to handle new format of the data, 3 categories in columns
Expand All @@ -8,6 +10,7 @@ May 2020: XXXX _ ver 1.1.1
- fixed a few bugs in itrends: failing when not arguments or only one geo.locn, were specified
- fixed data integrity functions not being exported


May 2020: Several new features _ ver 1.1
- added integrity and consistency check fns --integrity.check/consistency.check/data.checks--
- added "geo.loc" argument for report.summary() fn
Expand Down
25 changes: 21 additions & 4 deletions R/aux_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ return(cases.per.loc0)

#######################################################################


checkGeoLoc <- function(data, geo.loc=NULL) {
#' function to check the geographical location
#'
Expand All @@ -99,6 +100,12 @@ checkGeoLoc <- function(data, geo.loc=NULL) {
#' @keywords internal
#'


#########################
# obtain defns of geographical regions
regions <- geographicalRegions()
#########################

col.names <- names(data)
#print(col.names)

Expand All @@ -120,10 +127,20 @@ checkGeoLoc <- function(data, geo.loc=NULL) {
geo.loc <- countries.regions
} else {
for (geo.ind in geo.loc) {
if (!(toupper(geo.ind) %in% provinces.states) & !(toupper(geo.ind) %in% countries.regions) & !(toupper(geo.ind) == "ALL") ) {
warning(paste("Unrecognized region: ",geo.ind," will skip it!"))
# process pre-defined regions, eg. continents
# remove possible spaces, eg 'South America' --> "SOUTHAMERICA"
tgt <- gsub(" ","",toupper(geo.ind))
print(tgt); #print(names(regions))
if ( sum(tgt %in% names(regions)) != 0 ) {
#print(regions[tgt])
geo.locs <- c(geo.locs, checkGeoLoc(data,regions[tgt]) )
} else {
geo.locs <- c(geo.locs,geo.ind)
# individual entries, ie. countries
if (!(toupper(geo.ind) %in% provinces.states) & !(toupper(geo.ind) %in% countries.regions) & !(toupper(geo.ind) == "ALL") ) {
warning(paste("Unrecognized region: ",geo.ind," will skip it!"))
} else {
geo.locs <- c(geo.locs,geo.ind)
}
}
}

Expand All @@ -138,7 +155,7 @@ checkGeoLoc <- function(data, geo.loc=NULL) {
}
}

return(toupper(geo.loc))
return(toupper(unique(geo.loc)))
}


Expand Down
5 changes: 4 additions & 1 deletion R/covid19_anal.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ growth.rate <- function(data0, geo.loc=NULL, stride=1, info="", staticPlt=TRUE,
#' # read data for confirmed cases
#' data <- covid19.data("ts-confirmed")
#' # compute changes and growth rates per location for all the countries
#' growth.rate(data)
#' # growth.rate(data)
#' # compute changes and growth rates per location for 'Italy'
#' growth.rate(data,geo.loc="Italy")
#' # compute changes and growth rates per location for 'Italy' and 'Germany'
Expand Down Expand Up @@ -340,6 +340,9 @@ growth.rate <- function(data0, geo.loc=NULL, stride=1, info="", staticPlt=TRUE,
par(mfrow=c(1,2))
if (nrow(total.changes.per.day) > 1) {
mat.tgt <- (as.matrix(total.changes.per.day[,2:length(changes)]))
# deal with NA/nan/... setting to 0
mat.tgt[is.na(mat.tgt)] <- 0

# Heatmap.2
heatmap.2(mat.tgt,
dendrogram="none", trace='none',
Expand Down

0 comments on commit 501d00d

Please sign in to comment.