diff --git a/DESCRIPTION b/DESCRIPTION index e6e906d..300753d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,11 +1,13 @@ Package: eoR Type: Package -Title: What the Package Does (Title Case) +Title: Data Management Package (Title Case) Version: 0.1.0 -Author: Who wrote it -Maintainer: The package maintainer -Description: More about what it does (maybe more than one line) - Use four spaces when indenting paragraphs within the Description. -License: What license is it under? +Author: Rainer Walke +Maintainer: Rainer Walke +Description: It provides some classes for publicly available data + sources (HMD, DESTATIS). +License: GPL (>= 2) | file LICENCE Encoding: UTF-8 -LazyData: true +Depends: R (>= 3.2.0) +Imports: methods, data.table +LazyData: no diff --git a/R/eo1.R b/R/eo1.R index b5d21ab..8cc9bdf 100644 --- a/R/eo1.R +++ b/R/eo1.R @@ -388,172 +388,3 @@ readRegExp <- function(infile) #### -# example and trials - -# read all information from the file fltper_1x1 -# example data source: Human Mortality Database https://www.mortality.org/ -# period life tables 1x1 female -infile <- file.path("..","inst","extdata","DEUTNP.fltper_1x1.txt") - -o1 <- readLT1x1(infile) - -length((o1)) -o1 - -header1(o1) -lt1(o1) - -# descriptive tables and a ranges -lt1(o1)[, table(Year)] -lt1(o1)[, table(Age)] -lt1(o1)[, range(ex)] - -content(o1) -country(o1) -protocol(o1) - -# select some years -(o2 <- selectYears(o1, c(1999,2000))) -# descriptive tables and a ranges -lt1(o2)[, table(Year)] -lt1(o2)[, table(Age)] -lt1(o2)[, range(ex)] - -lt1(o2) - - -class(o1) -showClass("LT1") -showMethods("length") - - -# read all information from the file Exposures_1x1 -# example data source: Human Mortality Database https://www.mortality.org/ -# period life tables 1x1 female -infile2 <- file.path("..","inst","extdata","DEUTNP.Exposures_1x1.txt") - -e1 <- readEX1x1(infile2) - -length((e1)) -e1 - -header1(e1) -ex1(e1) - -# descriptive tables and a ranges -ex1(e1)[, table(Year)] -ex1(e1)[, table(Age)] -ex1(e1)[, range(AgeLow)] - -content(e1) -country(e1) -protocol(e1) - -# select some years -(e2 <- selectYears(e1, c(1999,2000))) -# descriptive tables and a ranges -ex1(e2)[, table(Year)] -ex1(e2)[, table(Age)] -ex1(e2)[, range(AgeLow)] - -ex1(e2) - -class(e1) -showClass("EX1") -showMethods("length") - -# read all information from 'GENESIS-Tabelle: 12613-02-02-4' -# Statistische ?mter des Bundes und der L?nder, Deutschland, 2019 -# Gestorbene nach Geschlecht, Nationalit?t und Altersgruppen - -# Jahressumme - regionale Tiefe: Kreise und krfr. St?dte -infile3 <- file.path("..","inst","extdata","12613-02-02-4.csv") - -d1 <- readRegDeath(infile3) - -length((d1)) -d1 - -header1(d1) -rd1(d1) - -# descriptive tables and a ranges -rd1(d1)[, table(Year)] -rd1(d1)[, table(Age_Name)] -rd1(d1)[, range(AgeLow)] - -content(d1) -country(d1) -protocol(d1) - -# select some years -(d2 <- selectYears(d1, c(2016))) -# descriptive tables and a ranges -rd1(d2)[, table(Year)] -rd1(d2)[, table(Age_Name)] -rd1(d2)[, range(AgeLow)] - -rd1(d2) - -# select a reagion -(d3 <- selectRegion(d2, "13003")) -# descriptive tables and a ranges -rd1(d3)[, table(Year)] -rd1(d3)[, table(Age_Name)] -rd1(d3)[, range(AgeLow)] - -rd1(d3) - - -class(d1) -showClass("RD1") -showMethods("length") - - -# read all information from 'GENESIS-Tabelle: 12411-03-03-4' -# Statistische ?mter des Bundes und der L?nder, Deutschland, 2019 -# Bev?lkerung nach Geschlecht, Nationalit?t und Altersgruppen -infile4 <- file.path("..","inst","extdata","12411-03-03-4.csv") - -r1 <- readRegExp(infile4) - -length((r1)) -r1 - -header1(r1) -re1(r1) - -## -# descriptive tables and a ranges -re1(r1)[, table(Year)] -re1(r1)[, table(Age_Name)] -re1(r1)[, range(AgeLow)] - -content(r1) -country(r1) -protocol(r1) - -# select some years -(r2 <- selectYears(r1, c(2016))) -# descriptive tables and a ranges -re1(r2)[, table(Year)] -re1(r2)[, table(Age_Name)] -re1(r2)[, range(AgeLow)] - -re1(r2) - -# select a reagion -(r3 <- selectRegion(r2, "13003")) -# descriptive tables and a ranges -re1(r3)[, table(Year)] -re1(r3)[, table(Age_Name)] -re1(r3)[, range(AgeLow)] - -re1(r3) - - -class(r1) -showClass("RE1") -showMethods("length") - - -sessionInfo() diff --git a/tests/Simple1.R b/tests/Simple1.R new file mode 100644 index 0000000..bc7fff6 --- /dev/null +++ b/tests/Simple1.R @@ -0,0 +1,175 @@ +# Rainer Walke, MPIDR Rostock + +source(file.path("..","R","eo1.R")) + +#### + +# example and trials + +# read all information from the file fltper_1x1 +# example data source: Human Mortality Database https://www.mortality.org/ +# period life tables 1x1 female +infile <- file.path("..","inst","extdata","DEUTNP.fltper_1x1.txt") + +o1 <- readLT1x1(infile) + +length((o1)) +o1 + +header1(o1) +lt1(o1) + +# descriptive tables and a ranges +lt1(o1)[, table(Year)] +lt1(o1)[, table(Age)] +lt1(o1)[, range(ex)] + +content(o1) +country(o1) +protocol(o1) + +# select some years +(o2 <- selectYears(o1, c(1999,2000))) +# descriptive tables and a ranges +lt1(o2)[, table(Year)] +lt1(o2)[, table(Age)] +lt1(o2)[, range(ex)] + +lt1(o2) + + +class(o1) +showClass("LT1") +showMethods("length") + + +# read all information from the file Exposures_1x1 +# example data source: Human Mortality Database https://www.mortality.org/ +# period life tables 1x1 female +infile2 <- file.path("..","inst","extdata","DEUTNP.Exposures_1x1.txt") + +e1 <- readEX1x1(infile2) + +length((e1)) +e1 + +header1(e1) +ex1(e1) + +# descriptive tables and a ranges +ex1(e1)[, table(Year)] +ex1(e1)[, table(Age)] +ex1(e1)[, range(AgeLow)] + +content(e1) +country(e1) +protocol(e1) + +# select some years +(e2 <- selectYears(e1, c(1999,2000))) +# descriptive tables and a ranges +ex1(e2)[, table(Year)] +ex1(e2)[, table(Age)] +ex1(e2)[, range(AgeLow)] + +ex1(e2) + +class(e1) +showClass("EX1") +showMethods("length") + +# read all information from 'GENESIS-Tabelle: 12613-02-02-4' +# Statistische ?mter des Bundes und der L?nder, Deutschland, 2019 +# Gestorbene nach Geschlecht, Nationalit?t und Altersgruppen - +# Jahressumme - regionale Tiefe: Kreise und krfr. St?dte +infile3 <- file.path("..","inst","extdata","12613-02-02-4.csv") + +d1 <- readRegDeath(infile3) + +length((d1)) +d1 + +header1(d1) +rd1(d1) + +# descriptive tables and a ranges +rd1(d1)[, table(Year)] +rd1(d1)[, table(Age_Name)] +rd1(d1)[, range(AgeLow)] + +content(d1) +country(d1) +protocol(d1) + +# select some years +(d2 <- selectYears(d1, c(2016))) +# descriptive tables and a ranges +rd1(d2)[, table(Year)] +rd1(d2)[, table(Age_Name)] +rd1(d2)[, range(AgeLow)] + +rd1(d2) + +# select a reagion +(d3 <- selectRegion(d2, "13003")) +# descriptive tables and a ranges +rd1(d3)[, table(Year)] +rd1(d3)[, table(Age_Name)] +rd1(d3)[, range(AgeLow)] + +rd1(d3) + + +class(d1) +showClass("RD1") +showMethods("length") + + +# read all information from 'GENESIS-Tabelle: 12411-03-03-4' +# Statistische ?mter des Bundes und der L?nder, Deutschland, 2019 +# Bev?lkerung nach Geschlecht, Nationalit?t und Altersgruppen +infile4 <- file.path("..","inst","extdata","12411-03-03-4.csv") + +r1 <- readRegExp(infile4) + +length((r1)) +r1 + +header1(r1) +re1(r1) + +## +# descriptive tables and a ranges +re1(r1)[, table(Year)] +re1(r1)[, table(Age_Name)] +re1(r1)[, range(AgeLow)] + +content(r1) +country(r1) +protocol(r1) + +# select some years +(r2 <- selectYears(r1, c(2016))) +# descriptive tables and a ranges +re1(r2)[, table(Year)] +re1(r2)[, table(Age_Name)] +re1(r2)[, range(AgeLow)] + +re1(r2) + +# select a reagion +(r3 <- selectRegion(r2, "13003")) +# descriptive tables and a ranges +re1(r3)[, table(Year)] +re1(r3)[, table(Age_Name)] +re1(r3)[, range(AgeLow)] + +re1(r3) + + +class(r1) +showClass("RE1") +showMethods("length") + + +sessionInfo()