Skip to content

Commit

Permalink
Merge pull request #96 from kgoldfeld/issue-93
Browse files Browse the repository at this point in the history
updateDef Coercion Error
  • Loading branch information
kgoldfeld committed Apr 25, 2021
2 parents 6fb6fcf + 99c93cc commit 6d3a295
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
13 changes: 9 additions & 4 deletions R/utility.R
Expand Up @@ -407,15 +407,16 @@ trimData <- function(dtOld, seqvar, eventvar, idvar = "id") {
#' @title Update definition table
#' @description Updates row definition table created by function
#' defData or defRead. (For tables created using defDataAdd
#' and defReadAdd use updateDefAdd.)
#' and defReadAdd use updateDefAdd.) Does not modify in-place.
#' @param dtDefs Definition table that will be modified
#' @param changevar Name of field definition that will be changed
#' @param newformula New formula definition (defaults to NULL)
#' @param newvariance New variance specification (defaults to NULL)
#' @param newdist New distribution definition (defaults to NULL)
#' @param newlink New link specification (defaults to NULL)
#' @param remove If set to TRUE, remove definition (defaults to FALSE)
#' @return A string that represents the desired formula
#' @param remove If set to TRUE, remove `changevar`from
#' definition (defaults to FALSE).
#' @return The updated data definition table.
#' @examples
#'
#' # Example 1
Expand All @@ -439,6 +440,9 @@ trimData <- function(dtOld, seqvar, eventvar, idvar = "id") {
#'
#' updateDef(dtDefs = defs, changevar = "x", remove = TRUE)
#' updateDef(dtDefs = defs, changevar = "z", remove = TRUE)
#'
#' # No changes to original definition:
#' defs
#' @export
#' @concept utility
#' @concept define_data
Expand Down Expand Up @@ -466,6 +470,7 @@ updateDef <- function(dtDefs, changevar, newformula = NULL,
# checks completed

xdef <- copy(dtDefs)
xdef[] <- lapply(xdef, as.character)
rowvar <- which(changevar == xdef$varname)

if (!is.null(newformula)) {
Expand Down Expand Up @@ -720,4 +725,4 @@ viewSplines <- function(knots, degree, theta) {
}

return(p)
}
}
10 changes: 7 additions & 3 deletions man/updateDef.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6d3a295

Please sign in to comment.