From bd76bf9c3a8a3e41788c7e394d481eba15f05edf Mon Sep 17 00:00:00 2001 From: Rainer Walke Date: Wed, 2 Oct 2019 13:25:39 +0200 Subject: [PATCH] improve documentation get rid of hello.R --- NAMESPACE | 1 - R/HMDClasses.R | 44 ++++++++++++++++++++++++++++++++++++-------- R/hello.R | 19 ------------------- man/LT1-class.Rd | 40 +++++++++++++++++++++++++++++++++++++--- man/hello.Rd | 12 ------------ 5 files changed, 73 insertions(+), 43 deletions(-) delete mode 100644 R/hello.R delete mode 100644 man/hello.Rd diff --git a/NAMESPACE b/NAMESPACE index 596454d..b85b42c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,7 +5,6 @@ export(Exposure1) export(LTable1) export(RegDeath1) export(RegExp1) -export(hello) export(readEX1x1) export(readLT1x1) export(readRegDeath) diff --git a/R/HMDClasses.R b/R/HMDClasses.R index 193a225..f6a373f 100644 --- a/R/HMDClasses.R +++ b/R/HMDClasses.R @@ -6,19 +6,24 @@ NULL NULL #### -# S4 class definitions -# class for life-tables 1x1 +## S4 class definitions -#' LT1 Class + +#' LT1 class for life-tables 1x1 #' -#' A \code{LT1} is used to .. +#' The class \code{LT1} stores life-table information in a systematic way. +#' It fits to Human Mortality Database (HMD) 1x1 period life tables. +#' See https://www.mortality.org/ for data details. +#' An LT1 instance stores the raw header content and the life table as data.table. +#' Further it adds a pure numeric age AgeLow to the data.table. #' #' @slot content describes the content -#' @slot country +#' @slot country regional entity #' @slot header includes the raw header information #' @slot lt1 ist the life table (data.table) #' @slot protocol contains the protocol information #' @export +#' @rdname LT1-class setClass("LT1", slots=c( header="vector", # file header @@ -29,8 +34,15 @@ setClass("LT1", ) ) -# slot getters +## slot getters + +#' LT1 header +#' +#' The \code{header}-method gets the raw header information of an LT1 object +#' @param x LT1-object +#' @return raw header information #' @export +#' @rdname LT1-class setMethod("header", "LT1", function(x) x@header) #' @export setMethod("lt1", "LT1", function(x) x@lt1) @@ -48,14 +60,30 @@ setReplaceMethod("lt1", "LT1", function(x, value) {x@lt1 <- value; validObject(x -# constructor +## constructor + +#' LT1 constructor +#' +#' The \code{LTable1}-constructor creates an LT1 object +#' @param object header lt1 content country protocol +#' @return LT1 object #' @export +#' @rdname LT1-class LTable1 <- function(header, lt1, content, country, protocol) new("LT1", header=header, lt1=lt1, content=content, country=country, protocol=protocol) -# methods +## methods + + +#' LT1 length +#' +#' The \code{length}-method gets the number of rows int the LT1 lt1 data.table +#' @param x LT1-object +#' @return number of rows #' @export +#' @rdname LT1-class setMethod("length", "LT1", function(x) dim(x@lt1)[1]) + #' @export setMethod("show", "LT1", function(object) diff --git a/R/hello.R b/R/hello.R deleted file mode 100644 index 7e4acf5..0000000 --- a/R/hello.R +++ /dev/null @@ -1,19 +0,0 @@ -# Hello, world! -# -# This is an example function named 'hello' -# which prints 'Hello, world!'. -# -# You can learn more about package authoring with RStudio at: -# -# http://r-pkgs.had.co.nz/ -# -# Some useful keyboard shortcuts for package authoring: -# -# Install Package: 'Ctrl + Shift + B' -# Check Package: 'Ctrl + Shift + E' -# Test Package: 'Ctrl + Shift + T' - -#' @export -hello <- function() { - print("Hello, world!") -} diff --git a/man/LT1-class.Rd b/man/LT1-class.Rd index edd269a..cd834af 100644 --- a/man/LT1-class.Rd +++ b/man/LT1-class.Rd @@ -3,16 +3,50 @@ \docType{class} \name{LT1-class} \alias{LT1-class} -\title{LT1 Class} +\alias{header,LT1-method} +\alias{LTable1} +\alias{length,LT1-method} +\title{LT1 class for life-tables 1x1} +\usage{ +\S4method{header}{LT1}(x) + +LTable1(header, lt1, content, country, protocol) + +\S4method{length}{LT1}(x) +} +\arguments{ +\item{x}{LT1-object} + +\item{object}{header lt1 content country protocol} + +\item{x}{LT1-object} +} +\value{ +raw header information + +LT1 object + +number of rows +} \description{ -A \code{LT1} is used to .. +The class \code{LT1} stores life-table information in a systematic way. +It fits to Human Mortality Database (HMD) 1x1 period life tables. +See https://www.mortality.org/ for data details. +An LT1 instance stores the raw header content and the life table as data.table. +Further it adds a pure numeric age AgeLow to the data.table. + +The \code{header}-method gets the raw header information of an LT1 object + +The \code{LTable1}-constructor creates an LT1 object + +The \code{length}-method gets the number of rows int the LT1 lt1 data.table } \section{Slots}{ \describe{ \item{\code{content}}{describes the content} -\item{\code{country}}{} +\item{\code{country}}{regional entity} \item{\code{header}}{includes the raw header information} diff --git a/man/hello.Rd b/man/hello.Rd deleted file mode 100644 index 0fa7c4b..0000000 --- a/man/hello.Rd +++ /dev/null @@ -1,12 +0,0 @@ -\name{hello} -\alias{hello} -\title{Hello, World!} -\usage{ -hello() -} -\description{ -Prints 'Hello, world!'. -} -\examples{ -hello() -}