From 1469628fed1b492e6adc52ee3cfd10cbc1c0f8cc Mon Sep 17 00:00:00 2001 From: Rainer Walke Date: Wed, 2 Oct 2019 10:06:56 +0200 Subject: [PATCH] roxygen2 creates the NAMESPACE now --- NAMESPACE | 53 ++++++++++++++++++++++++++++------------------ R/GENESISClasses.R | 37 ++++++++++++++++++++++++++++++++ R/HMDClasses.R | 30 ++++++++++++++++++++++++++ R/hello.R | 1 + 4 files changed, 100 insertions(+), 21 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index aedec03..2198e8b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/GENESISClasses.R b/R/GENESISClasses.R index b70be71..002a736 100644 --- a/R/GENESISClasses.R +++ b/R/GENESISClasses.R @@ -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 @@ -17,34 +23,47 @@ 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)) @@ -52,6 +71,7 @@ setMethod("selectRegion", "RD1", function(x, selectRegion) { ) # validity method +#' @export setValidity("RD1", function(object) { msg <- NULL @@ -71,6 +91,7 @@ setValidity("RD1", #### # Class for 'GENESIS-Tabelle: 12411-03-03-4' +#' @export setClass("RE1", slots=c( header="vector", # file header @@ -83,34 +104,47 @@ 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)) @@ -118,6 +152,7 @@ setMethod("selectRegion", "RE1", function(x, selectRegion) { ) # validity method +#' @export setValidity("RE1", function(object) { msg <- NULL @@ -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") @@ -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") diff --git a/R/HMDClasses.R b/R/HMDClasses.R index dee6749..f9dd66c 100644 --- a/R/HMDClasses.R +++ b/R/HMDClasses.R @@ -2,6 +2,10 @@ require(data.table) +#' @importFrom methods new show validObject +NULL +#' @importFrom data.table := +NULL #### # S4 class definitions @@ -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 @@ -27,29 +32,39 @@ 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)) @@ -57,6 +72,7 @@ setMethod("selectYears", "LT1", function(x, selectYears) { ) # validity method +#' @export setValidity("LT1", function(object) { msg <- NULL @@ -84,6 +100,7 @@ setValidity("LT1", #### # Class for exposures 1x1 +#' @export setClass("EX1", slots=c( header="vector", # file header @@ -95,27 +112,37 @@ 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)) @@ -123,6 +150,7 @@ setMethod("selectYears", "EX1", function(x, selectYears) { ) # validity method +#' @export setValidity("EX1", function(object) { msg <- NULL @@ -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) @@ -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) diff --git a/R/hello.R b/R/hello.R index a793395..7e4acf5 100644 --- a/R/hello.R +++ b/R/hello.R @@ -13,6 +13,7 @@ # Check Package: 'Ctrl + Shift + E' # Test Package: 'Ctrl + Shift + T' +#' @export hello <- function() { print("Hello, world!") }