diff --git a/DESCRIPTION b/DESCRIPTION index e214c3d41..3b185fe81 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 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 . 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. diff --git a/NEWS b/NEWS index b1d3b428d..6f2939b62 100644 --- a/NEWS +++ b/NEWS @@ -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 @@ -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 diff --git a/R/aux_utils.R b/R/aux_utils.R index bb3b28592..6d56ed30a 100644 --- a/R/aux_utils.R +++ b/R/aux_utils.R @@ -88,6 +88,7 @@ return(cases.per.loc0) ####################################################################### + checkGeoLoc <- function(data, geo.loc=NULL) { #' function to check the geographical location #' @@ -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) @@ -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) + } } } @@ -138,7 +155,7 @@ checkGeoLoc <- function(data, geo.loc=NULL) { } } - return(toupper(geo.loc)) + return(toupper(unique(geo.loc))) } diff --git a/R/covid19_anal.R b/R/covid19_anal.R index cd38a9b63..b18192b28 100644 --- a/R/covid19_anal.R +++ b/R/covid19_anal.R @@ -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' @@ -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',