Skip to content

Commit

Permalink
roxygen2 creates the NAMESPACE now
Browse files Browse the repository at this point in the history
  • Loading branch information
walke committed Oct 2, 2019
1 parent 4da4515 commit 1469628
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 21 deletions.
53 changes: 32 additions & 21 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
# exportPattern("^[[:alpha:]]+")
# Generated by roxygen2: do not edit by hand

export()
export(Exposure1)
export(LTable1)
export(RegDeath1)
export(RegExp1)
export(hello)
export(readEX1x1)
export(readLT1x1)
export(readRegDeath)
export(readRegExp)
exportClasses(EX1)
exportClasses(LT1)
exportClasses(RD1)
exportClasses(RE1)

## Generics and functions defined in this package
export("header", "footer", "lt1",
"content",
"country",
"protocol", "lt1<-",
"selectYears", "ex1", "ex1<-", "rd1", "rd1<-",
"selectRegion", "re1", "re1<-")

export(readLT1x1)
export(readEX1x1)
export(readRegDeath)
export(readRegExp)

export(hello)

importFrom("methods", "new", "validObject")
importFrom("data.table", ":=")


exportMethods("ex1<-")
exportMethods("lt1<-")
exportMethods("rd1<-")
exportMethods("re1<-")
exportMethods(content)
exportMethods(country)
exportMethods(ex1)
exportMethods(footer)
exportMethods(header)
exportMethods(length)
exportMethods(lt1)
exportMethods(protocol)
exportMethods(rd1)
exportMethods(re1)
exportMethods(selectRegion)
exportMethods(selectYears)
exportMethods(show)
importFrom(data.table,":=")
importFrom(methods,new)
importFrom(methods,show)
importFrom(methods,validObject)
37 changes: 37 additions & 0 deletions R/GENESISClasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

require(data.table)

#' @importFrom methods new show validObject
NULL
#' @importFrom data.table :=
NULL

####
# Class for 'GENESIS-Tabelle: 12613-02-02-4'

#' @export
setClass("RD1",
slots=c(
header="vector", # file header
Expand All @@ -17,41 +23,55 @@ setClass("RD1",
)

# slot getters
#' @export
setMethod("header", "RD1", function(x) x@header)
#' @export
setMethod("footer", "RD1", function(x) x@footer)
#' @export
setMethod("rd1", "RD1", function(x) x@rd1)

#' @export
setMethod("content", "RD1", function(x) x@content)
#' @export
setMethod("country", "RD1", function(x) x@country)
#' @export
setMethod("protocol", "RD1", function(x) x@protocol)

# slot setters
#' @export
setReplaceMethod("rd1", "RD1", function(x, value) {x@rd1 <- value; validObject(x); x})

# constructor
#' @export
RegDeath1 <- function(header, footer, rd1, content, country, protocol)
new("RD1", header=header, footer=footer, rd1=rd1, content=content, country=country, protocol=protocol)

# methods
#' @export
setMethod("length", "RD1", function(x) dim(x@rd1)[1])

#' @export
setMethod("show", "RD1",
function(object)
cat(class(object), "instance with length", length(object), "\n")
)

#' @export
setMethod("selectYears", "RD1", function(x, selectYears) {
.rd1 <- x@rd1[Year %in% selectYears]
return(new("RD1", header=x@header, footer=x@footer, rd1=.rd1, content=x@content, country=x@country, protocol=x@protocol))
}
)

#' @export
setMethod("selectRegion", "RD1", function(x, selectRegion) {
.rd1 <- x@rd1[Region_Code %in% selectRegion]
return(new("RD1", header=x@header, footer=x@footer, rd1=.rd1, content=x@content, country=x@country, protocol=x@protocol))
}
)

# validity method
#' @export
setValidity("RD1",
function(object) {
msg <- NULL
Expand All @@ -71,6 +91,7 @@ setValidity("RD1",
####
# Class for 'GENESIS-Tabelle: 12411-03-03-4'

#' @export
setClass("RE1",
slots=c(
header="vector", # file header
Expand All @@ -83,41 +104,55 @@ setClass("RE1",
)

# slot getters
#' @export
setMethod("header", "RE1", function(x) x@header)
#' @export
setMethod("footer", "RE1", function(x) x@footer)
#' @export
setMethod("re1", "RE1", function(x) x@re1)

#' @export
setMethod("content", "RE1", function(x) x@content)
#' @export
setMethod("country", "RE1", function(x) x@country)
#' @export
setMethod("protocol", "RE1", function(x) x@protocol)

# slot setters
#' @export
setReplaceMethod("re1", "RE1", function(x, value) {x@re1 <- value; validObject(x); x})

# constructor
#' @export
RegExp1 <- function(header, footer, re1, content, country, protocol)
new("RE1", header=header, footer, re1=re1, content=content, country=country, protocol=protocol)

# methods
#' @export
setMethod("length", "RE1", function(x) dim(x@re1)[1])

#' @export
setMethod("show", "RE1",
function(object)
cat(class(object), "instance with length", length(object), "\n")
)

#' @export
setMethod("selectYears", "RE1", function(x, selectYears) {
.re1 <- x@re1[Year %in% selectYears]
return(new("RE1", header=x@header, footer=x@footer, re1=.re1, content=x@content, country=x@country, protocol=x@protocol))
}
)

#' @export
setMethod("selectRegion", "RE1", function(x, selectRegion) {
.re1 <- x@re1[Region_Code %in% selectRegion]
return(new("RE1", header=x@header, footer=x@footer, re1=.re1, content=x@content, country=x@country, protocol=x@protocol))
}
)

# validity method
#' @export
setValidity("RE1",
function(object) {
msg <- NULL
Expand All @@ -137,6 +172,7 @@ setValidity("RE1",

# read all information from 'GENESIS-Tabelle: 12613-02-02-4'
# Statistische Ämter des Bundes und der Länder, Deutschland, 2019
#' @export
readRegDeath <- function(infile)
{
bb <- scan(infile, what=character(), blank.lines.skip = FALSE, encoding="ANSI", sep="\n")
Expand Down Expand Up @@ -175,6 +211,7 @@ readRegDeath <- function(infile)

# read all information from 'GENESIS-Tabelle: 12613-02-02-4'
# Statistische Ämter des Bundes und der Länder, Deutschland, 2019
#' @export
readRegExp <- function(infile)
{
bb <- scan(infile, what=character(), blank.lines.skip = FALSE, encoding="ANSI", sep="\n")
Expand Down
30 changes: 30 additions & 0 deletions R/HMDClasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

require(data.table)

#' @importFrom methods new show validObject
NULL
#' @importFrom data.table :=
NULL
####

# S4 class definitions
Expand All @@ -16,6 +20,7 @@ require(data.table)
#' @slot header includes the raw header information
#' @slot lt1 ist the life table (data.table)
#' @slot protocol contains the protocol information
#' @export
setClass("LT1",
slots=c(
header="vector", # file header
Expand All @@ -27,36 +32,47 @@ setClass("LT1",
)

# slot getters
#' @export
setMethod("header", "LT1", function(x) x@header)
#' @export
setMethod("lt1", "LT1", function(x) x@lt1)

#' @export
setMethod("content", "LT1", function(x) x@content)
#' @export
setMethod("country", "LT1", function(x) x@country)
#' @export
setMethod("protocol", "LT1", function(x) x@protocol)

# slot setters
#' @export
setReplaceMethod("lt1", "LT1", function(x, value) {x@lt1 <- value; validObject(x); x})



# constructor
#' @export
LTable1 <- function(header, lt1, content, country, protocol)
new("LT1", header=header, lt1=lt1, content=content, country=country, protocol=protocol)

# methods
#' @export
setMethod("length", "LT1", function(x) dim(x@lt1)[1])
#' @export
setMethod("show", "LT1",
function(object)
cat(class(object), "instance with length", length(object), "\n")
)

#' @export
setMethod("selectYears", "LT1", function(x, selectYears) {
.lt1 <- x@lt1[Year %in% selectYears]
return(new("LT1", header=x@header, lt1=.lt1, content=x@content, country=x@country, protocol=x@protocol))
}
)

# validity method
#' @export
setValidity("LT1",
function(object) {
msg <- NULL
Expand Down Expand Up @@ -84,6 +100,7 @@ setValidity("LT1",
####
# Class for exposures 1x1

#' @export
setClass("EX1",
slots=c(
header="vector", # file header
Expand All @@ -95,34 +112,45 @@ setClass("EX1",
)

# slot getters
#' @export
setMethod("header", "EX1", function(x) x@header)
#' @export
setMethod("ex1", "EX1", function(x) x@ex1)

#' @export
setMethod("content", "EX1", function(x) x@content)
#' @export
setMethod("country", "EX1", function(x) x@country)
#' @export
setMethod("protocol", "EX1", function(x) x@protocol)

# slot setters
#' @export
setReplaceMethod("ex1", "EX1", function(x, value) {x@ex1 <- value; validObject(x); x})

# constructor
#' @export
Exposure1 <- function(header, ex1, content, country, protocol)
new("EX1", header=header, ex1=ex1, content=content, country=country, protocol=protocol)

# methods
#' @export
setMethod("length", "EX1", function(x) dim(x@ex1)[1])
#' @export
setMethod("show", "EX1",
function(object)
cat(class(object), "instance with length", length(object), "\n")
)

#' @export
setMethod("selectYears", "EX1", function(x, selectYears) {
.ex1 <- x@ex1[Year %in% selectYears]
return(new("EX1", header=x@header, ex1=.ex1, content=x@content, country=x@country, protocol=x@protocol))
}
)

# validity method
#' @export
setValidity("EX1",
function(object) {
msg <- NULL
Expand All @@ -146,6 +174,7 @@ setValidity("EX1",

# read all information from the file 1x1 period life table
# Human Mortality Database https://www.mortality.org/
#' @export
readLT1x1 <- function(infile)
{
LT0 <- readLines(infile, n=2)
Expand All @@ -162,6 +191,7 @@ readLT1x1 <- function(infile)

# read all information from the file 1x1 exposure table
# Human Mortality Database https://www.mortality.org/
#' @export
readEX1x1 <- function(infile)
{
EX0 <- readLines(infile, n=2)
Expand Down
1 change: 1 addition & 0 deletions R/hello.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# Check Package: 'Ctrl + Shift + E'
# Test Package: 'Ctrl + Shift + T'

#' @export
hello <- function() {
print("Hello, world!")
}

0 comments on commit 1469628

Please sign in to comment.