Skip to content

Commit

Permalink
modify DESCRIPTION, divide the main program into two parts, classes a…
Browse files Browse the repository at this point in the history
…nd tests
  • Loading branch information
walke committed Sep 20, 2019
1 parent a22b1b6 commit f30ca61
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 176 deletions.
16 changes: 9 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 <yourself@somewhere.net>
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 <walke@demogr.mpg.de>
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
169 changes: 0 additions & 169 deletions R/eo1.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
175 changes: 175 additions & 0 deletions tests/Simple1.R
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit f30ca61

Please sign in to comment.