diff --git a/DESCRIPTION b/DESCRIPTION index a252782..6e80b2c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -102,5 +102,5 @@ Collate: 'whipple.R' 'dataSets.R' 'zzz.R' -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Encoding: UTF-8 diff --git a/NAMESPACE b/NAMESPACE index e0c4d7d..e307e5b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,7 @@ # Generated by roxygen2: do not edit by hand +S3method(as.array,spTable) +S3method(as.table,spTable) S3method(calibVars,data.frame) S3method(calibVars,default) S3method(calibVars,matrix) @@ -14,12 +16,17 @@ S3method(covWt,data.frame) S3method(covWt,dataObj) S3method(covWt,default) S3method(covWt,matrix) +S3method(getExclude,data.frame) +S3method(getExclude,data.table) +S3method(getExclude,default) S3method(meanWt,dataObj) S3method(meanWt,default) +S3method(plot,spTable) S3method(prepBwplotStats,data.frame) S3method(prepBwplotStats,default) S3method(prepCdf,data.frame) S3method(prepCdf,default) +S3method(print,spTable) S3method(quantileWt,dataObj) S3method(quantileWt,default) S3method(varWt,dataObj) @@ -50,6 +57,7 @@ export(getCat) export(getCdf) export(getCitizenship) export(getEcoStat) +export(getExclude) export(getGender) export(getHsize) export(ipu) diff --git a/R/calibPop.R b/R/calibPop.R index e1cb087..7ef631b 100755 --- a/R/calibPop.R +++ b/R/calibPop.R @@ -296,8 +296,10 @@ multiply_data <- function(data0,params,redist.var,split){ #' @param observe.break When objective value has been saved \code{observe.times}-times the coefficient of variation is calculated over saved values; if the coefficient of variation falls below \code{observe.break} #' simmulated annealing terminates. This repeats for each new set of \code{observe.times} new values of the objecive function. Can help save run time if objective value does not improve much. Disable this termination by either setting \code{observe.times=0} or \code{observe.break=0}. #' @param n.forceCooldown integer, if the solution does not move for \code{n.forceCooldown} iterations then a cooldown is automatically done. -#' @param hhTables information on population margins for households -#' @param persTables information on population margins for persons +#' @param hhTables Information on population margins for households. Can bei either a single \code{data.table} or \code{data.frame} or a list with multiple \code{data.tables}s or \code{data.frame}s. +#' Each table must have one column named \code{Freq} and all other columns holding variable(s) of the synthetic population. Each row in this table corresponds to a the frequency count a one of the variable combination in that table, see examples. +#' @param persTables Information on population margins for persons. Can bei either a single \code{data.table} or \code{data.frame} or a list with multiple \code{data.tables}s or \code{data.frame}s. +#' Each table must have one column named \code{Freq} and all other columns holding variable(s) of the synthetic population. Each row in this table corresponds to a the frequency count a one of the variable combination in that table, see examples. #' @param redist.var single column in the population which can be redistributed in each `split`. Still experimental! #' @param redist.var.factor numeric in the interval (0,1]. Used in combinationo with `redist.var`, still experimental! #' @return Returns an object of class \code{\linkS4class{simPopObj}} with an diff --git a/R/simPop-package.R b/R/simPop-package.R index 0eb8cce..ad8f6c9 100644 --- a/R/simPop-package.R +++ b/R/simPop-package.R @@ -50,7 +50,6 @@ #' #' @name simPop-package #' @aliases simPop-package simPop -#' @docType package #' @author Bernhard Meindl, Matthias Templ, Andreas Alfons, Alexander Kowarik, #' #' Maintainer: Matthias Templ @@ -68,6 +67,7 @@ #' \emph{Privacy in Statistical Databases}, \strong{6344} of Lecture Notes in Computer Science, 174--186. Springer Verlag, Heidelberg. \doi{10.1007/978-3-642-15838-4_16} #' #' @keywords package +#' #' @examples #' #' ## we use synthetic eusilcS survey sample data @@ -99,4 +99,5 @@ #' ## using different methods, calibrating surveys or populations, etc. #' ## -- see Templ et al. (2017) for more details. #' +"_PACKAGE" NULL diff --git a/R/spTable.R b/R/spTable.R index 13e5734..51dd463 100644 --- a/R/spTable.R +++ b/R/spTable.R @@ -69,6 +69,7 @@ spTable <- function(inp, select) { } # methods for class "spTable" +#' @export as.array.spTable <- function(x, ...) { values <- c(as.integer(x$expected), as.integer(x$realized)) d <- c(dim(x$expected), 2) @@ -77,14 +78,17 @@ as.array.spTable <- function(x, ...) { array(values, dim=d, dimnames=dn) } +#' @export as.table.spTable <- function(x, ...) { tab <- as.array(x) class(tab) <- "table" tab } +#' @export plot.spTable <- function(x, ...) spMosaic(x, ...) +#' @export print.spTable <- function(x, ...) { # expected (from sample) cat("Expected:\n") diff --git a/R/utils.R b/R/utils.R index 5c45adf..4ec908a 100644 --- a/R/utils.R +++ b/R/utils.R @@ -86,11 +86,15 @@ dropLevels <- function(x, select = names(x)) { ## get which observations contain NAs (and need to be excluded) +#' @export getExclude <- function(x, ...) UseMethod("getExclude") +#' @export getExclude.default <- function(x, ...) which(is.na(x)) +#' @export getExclude.data.frame <- function(x, ...) { unique(which(is.na(x), arr.ind=TRUE)[, 1]) } +#' @export getExclude.data.table <- function(x, ...) { unique(which(is.na(x), arr.ind=TRUE)[, 1]) } diff --git a/man/calibPop.Rd b/man/calibPop.Rd index 34819a5..46aef4c 100644 --- a/man/calibPop.Rd +++ b/man/calibPop.Rd @@ -101,9 +101,11 @@ simmulated annealing terminates. This repeats for each new set of \code{observe. provided, however only if \code{split} is NULL. Otherwise the computation is performed in parallel and no useful output can be provided.} -\item{hhTables}{information on population margins for households} +\item{hhTables}{Information on population margins for households. Can bei either a single \code{data.table} or \code{data.frame} or a list with multiple \code{data.tables}s or \code{data.frame}s. +Each table must have one column named \code{Freq} and all other columns holding variable(s) of the synthetic population. Each row in this table corresponds to a the frequency count a one of the variable combination in that table, see examples.} -\item{persTables}{information on population margins for persons} +\item{persTables}{Information on population margins for persons. Can bei either a single \code{data.table} or \code{data.frame} or a list with multiple \code{data.tables}s or \code{data.frame}s. +Each table must have one column named \code{Freq} and all other columns holding variable(s) of the synthetic population. Each row in this table corresponds to a the frequency count a one of the variable combination in that table, see examples.} \item{redist.var}{single column in the population which can be redistributed in each `split`. Still experimental!}