From a16ce10690ec325c34913c77bd0292a8e4e147ab Mon Sep 17 00:00:00 2001 From: Rainer Walke Date: Tue, 29 Oct 2019 16:09:29 +0100 Subject: [PATCH] add Date1/Year to a class --- R/GENESISClasses.R | 29 +++++++++++++++-------------- man/RD1-class.Rd | 2 +- man/RE1-class.Rd | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/R/GENESISClasses.R b/R/GENESISClasses.R index c933180..f0ad0a7 100644 --- a/R/GENESISClasses.R +++ b/R/GENESISClasses.R @@ -14,7 +14,7 @@ NULL #' #' This \code{RD1} class fits to the GENESIS table 12613-02-02-4. #' See https://www.regionalstatistik.de/genesis/online for data details. -#' An RD1 instance stores the raw header, the raw footer, the content, +#' An RD1 instance stores the raw header, the raw footer, the content, #' the version protocol and regional information and the #' death count information as a data.table object. Further it stores a second data.table #' with the total sums information. @@ -33,7 +33,7 @@ setClass("RD1", header="vector", # file header footer="vector", # file footer rd1="data.table", # exposure table - rd1total="data.table", # exposure table total sums + rd1total="data.table", # exposure table total sums content="character", # content region="character", # region protocol="character" # protocol version @@ -204,7 +204,7 @@ setValidity("RD1", #' #' This \code{RE1} class fits to the GENESIS table 12411-03-03-4. #' See https://www.regionalstatistik.de/genesis/online for data details. -#' An RE1 instance stores the raw header, the raw footer, the content, +#' An RE1 instance stores the raw header, the raw footer, the content, #' the version protocol and regional information and the #' exposure information as a data.table object. Further it stores a second data.table #' with the total sums information. @@ -375,7 +375,7 @@ setValidity("RE1", function(object) { msg <- NULL valid <- TRUE - re1colnames <-c("Region_Code","Region_Name","Age_Name","Total1","Male","Female","D_Total","D_Male","D_Female", + re1colnames <-c("Date1","Region_Code","Region_Name","Age_Name","Total1","Male","Female","D_Total","D_Male","D_Female", "A_Total","A_Male","A_Female", "Year", "AgeLow") if (!all(re1colnames %in% colnames(object@re1))) { valid <- FALSE @@ -389,7 +389,7 @@ setValidity("RE1", #### # read all information from 'GENESIS-Tabelle: 12613-02-02-4' -# Statistische Ämter des Bundes und der Länder, Deutschland, 2019 +# Statistische Ämter des Bundes und der Länder, Deutschland, 2019 #' RD1 readRegDeath #' @@ -415,11 +415,11 @@ readRegDeath <- function(infile) data.table::setnames(rdft, c("V1","V2","V3","V4","V5","V6","V7","V8","V9","V10"), c("Year","Region_Code","Region_Name","Age_Name","Total1","Male","Female","D_Total","D_Male","D_Female")) - + # extract the total sums Age_Name <- NULL # to prevent a note rd1total <- rdft[Age_Name=="Insgesamt"] - + # merge the lower age limit age_code1 <- data.table::data.table(Age_Name=c("unter 1 Jahr","1 bis unter 5 Jahre", "5 bis unter 10 Jahre","10 bis unter 15 Jahre", @@ -441,7 +441,7 @@ readRegDeath <- function(infile) # read all information from 'GENESIS-Tabelle: 12411-03-03-4' -# Statistische Ämter des Bundes und der Länder, Deutschland, 2019 +# Statistische Ämter des Bundes und der Länder, Deutschland, 2019 #' RE1 readRegExp #' @@ -465,18 +465,19 @@ readRegExp <- function(infile) rexpt <- data.table::fread(infile, skip=h2, nrows=(f1-h2-1)) - data.table::setnames(rexpt, c("V1","V2","V3","V4","V5","V6","V7","V8","V9","V10","V11","V12"), - c("Region_Code","Region_Name","Age_Name","Total1","Male","Female","D_Total","D_Male","D_Female", + data.table::setnames(rexpt, c("V1","V2","V3","V4","V5","V6","V7","V8","V9","V10","V11","V12","V13"), + c("Date1","Region_Code","Region_Name","Age_Name","Total1","Male","Female","D_Total","D_Male","D_Female", "A_Total","A_Male","A_Female")) # add the year - Year <- NULL # avoid NOTE - rexpt[, Year:=2016] + Year <- NULL # avoid NOTE + Date1 <- NULL # avoid NOTE + rexpt[, Year := as.integer(sub("31.12.","",Date1))] Age_Name <- NULL # to prevent a note # extract the total sums re1total <- rexpt[Age_Name=="Insgesamt"] - - + + # merge the lower age limit age_code2 <- data.table::data.table(Age_Name=c("unter 3 Jahre","3 bis unter 6 Jahre", "6 bis unter 10 Jahre","10 bis unter 15 Jahre", diff --git a/man/RD1-class.Rd b/man/RD1-class.Rd index 53db028..651d993 100644 --- a/man/RD1-class.Rd +++ b/man/RD1-class.Rd @@ -124,7 +124,7 @@ The \code{readRegDeath}-method reads all information from 'GENESIS-Tabelle: 1261 \details{ This \code{RD1} class fits to the GENESIS table 12613-02-02-4. See https://www.regionalstatistik.de/genesis/online for data details. -An RD1 instance stores the raw header, the raw footer, the content, +An RD1 instance stores the raw header, the raw footer, the content, the version protocol and regional information and the death count information as a data.table object. Further it stores a second data.table with the total sums information. diff --git a/man/RE1-class.Rd b/man/RE1-class.Rd index 05e62ba..f7725d0 100644 --- a/man/RE1-class.Rd +++ b/man/RE1-class.Rd @@ -124,7 +124,7 @@ The \code{readRegExp}-method reads all information from 'GENESIS-Tabelle: 12411- \details{ This \code{RE1} class fits to the GENESIS table 12411-03-03-4. See https://www.regionalstatistik.de/genesis/online for data details. -An RE1 instance stores the raw header, the raw footer, the content, +An RE1 instance stores the raw header, the raw footer, the content, the version protocol and regional information and the exposure information as a data.table object. Further it stores a second data.table with the total sums information.