Skip to content

Commit

Permalink
docs: fix S3 method exports
Browse files Browse the repository at this point in the history
  • Loading branch information
niekdt committed Jan 12, 2024
1 parent c802e3f commit 2db0782
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 84 deletions.
60 changes: 30 additions & 30 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
# Generated by roxygen2: do not edit by hand

S3method("[",lcModels)
S3method(as.data.frame,lcMethod)
S3method(R.utils::evaluate,lcMethod)
S3method(as.data.frame,lcMethods)
S3method(as.data.frame,lcModels)
S3method(as.list,lcMethod)
S3method(as.list,lcModels)
S3method(coef,lcModel)
S3method(base::as.character,lcMetaMethod)
S3method(base::as.character,lcMethod)
S3method(base::as.data.frame,lcMethod)
S3method(base::as.list,lcMethod)
S3method(base::merge,formula)
S3method(base::print,lcMethod)
S3method(coef,lcModelCrimCV)
S3method(coef,lcModelFlexmix)
S3method(coef,lcModelFunFEM)
S3method(coef,lcModelLMKM)
S3method(coef,lcModelMixAK_GLMM)
S3method(coef,lcModelMixTVEM)
S3method(coef,lcModelMixtoolsGMM)
S3method(deviance,lcModel)
S3method(deviance,lcModelMixAK_GLMM)
S3method(df.residual,lcModel)
S3method(evaluate,lcMethod)
S3method(fitted,lcApproxModel)
S3method(fitted,lcModel)
S3method(fitted,lcModelFlexmix)
S3method(fitted,lcModelFunFEM)
S3method(fitted,lcModelLcmmGMM)
S3method(formula,lcMethod)
S3method(formula,lcModel)
S3method(getCall,lcMetaMethod)
S3method(getCall,lcMethod)
S3method(getCall,lcModel)
S3method(logLik,lcModel)
S3method(logLik,lcModelCrimCV)
S3method(logLik,lcModelFlexmix)
Expand All @@ -41,25 +34,39 @@ S3method(logLik,lcModelMixtoolsRM)
S3method(max,lcModels)
S3method(min,lcModels)
S3method(model.data,lcModel)
S3method(model.frame,lcModel)
S3method(model.matrix,lcModelLcmmGMM)
S3method(nobs,lcModel)
S3method(nobs,lcModelLcmmGMM)
S3method(predict,lcModel)
S3method(predict,lcModelMixTVEM)
S3method(print,lcMethod)
S3method(print,lcModels)
S3method(residuals,lcModel)
S3method(sigma,lcModel)
S3method(sigma,lcModelLcmmGMM)
S3method(sigma,lcModelMixTVEM)
S3method(sigma,lcModelMixtoolsGMM)
S3method(stats::coef,GLMM_MCMC)
S3method(stats::coef,lcModel)
S3method(stats::coef,lcModelMixAK_GLMM)
S3method(stats::coef,lcModelMixAK_GLMMlist)
S3method(stats::deviance,GLMM_MCMC)
S3method(stats::deviance,lcModel)
S3method(stats::deviance,lcModelMixAK_GLMM)
S3method(stats::deviance,lcModelMixAK_GLMMlist)
S3method(stats::df.residual,lcModel)
S3method(stats::fitted,lcModel)
S3method(stats::formula,lcMethod)
S3method(stats::formula,lcModel)
S3method(stats::getCall,lcMetaMethod)
S3method(stats::getCall,lcMethod)
S3method(stats::getCall,lcModel)
S3method(stats::model.frame,lcModel)
S3method(stats::nobs,lcModel)
S3method(stats::predict,lcModel)
S3method(stats::residuals,lcModel)
S3method(stats::sigma,lcModel)
S3method(stats::time,lcModel)
S3method(stats::update,lcMetaMethod)
S3method(stats::update,lcModel)
S3method(subset,lcModels)
S3method(summary,lcModel)
S3method(time,lcModel)
S3method(update,lcMetaMethod)
S3method(update,lcMethod)
S3method(update,lcModel)
export("clusterNames<-")
export(APPA)
export(OCC)
Expand Down Expand Up @@ -262,13 +269,6 @@ importFrom(stats,getCall)
importFrom(stats,logLik)
importFrom(stats,mahalanobis)
importFrom(stats,model.frame)
importFrom(stats,model.matrix)
importFrom(stats,nobs)
importFrom(stats,predict)
importFrom(stats,residuals)
importFrom(stats,sigma)
importFrom(stats,time)
importFrom(stats,update)
importFrom(stats,weighted.mean)
importFrom(utils,capture.output)
importFrom(utils,combn)
Expand Down
18 changes: 18 additions & 0 deletions R/formula.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ is.formula = function(x) {
inherits(x, 'formula')
}


hasResponse = function(f) {
if (is.formula(f)) {
tt = terms(f)
Expand All @@ -11,6 +12,7 @@ hasResponse = function(f) {
attr(tt, 'response') != 0
}


hasIntercept = function(f) {
if (is.formula(f)) {
tt = terms(f)
Expand All @@ -20,10 +22,12 @@ hasIntercept = function(f) {
attr(tt, 'intercept') != 0
}


hasSingleResponse = function(f) {
hasResponse(f) && length(getResponse(f)) == 1
}


getResponse = function(f) {
if (hasResponse(f)) {
update(f, . ~ 1) %>% all.vars()
Expand All @@ -33,22 +37,26 @@ getResponse = function(f) {
}
}


getREterms = function(f) {
.loadOptionalPackage('lme4')
terms = lme4::findbars(f)
}


REtermAsFormula = function(term) {
assert_that(is.call(term))
assert_that(!is.formula(term))
as.character(term)[2] %>% reformulate
}


getREGroupName = function(term) {
assert_that(is.call(term))
as.character(term)[3]
}


getCovariates = function(f) {
if(is.null(f)) {
character()
Expand All @@ -57,14 +65,17 @@ getCovariates = function(f) {
}
}


hasCovariates = function(f) {
length(getCovariates(f)) > 0
}


hasRE = function(f) {
length(getREterms(f)) > 0
}


addInteraction = function(f, var) {
assert_that(is.formula(f))
assert_that(is.character(var))
Expand All @@ -91,6 +102,8 @@ addInteraction = function(f, var) {
}
}


#' @exportS3Method base::merge
merge.formula = function(x, y, ...) {
assert_that(is.formula(x))
assert_that(is.formula(y))
Expand All @@ -115,6 +128,7 @@ merge.formula = function(x, y, ...) {
}
}


dropResponse = function(f) {
if (hasResponse(f)) {
update(f, NULL ~ .)
Expand All @@ -123,6 +137,7 @@ dropResponse = function(f) {
}
}


dropIntercept = function(f) {
if (hasIntercept(f)) {
update(f, ~ .+-1)
Expand All @@ -131,6 +146,7 @@ dropIntercept = function(f) {
}
}


#' @noRd
#' @importFrom stats drop.terms
#' @title Drop random-effects component from a formula
Expand Down Expand Up @@ -184,6 +200,7 @@ getSpecialTerms = function(f, special) {
vapply(deparse, FUN.VALUE = '')
}


#' @noRd
#' @title Get special terms as formula
#' @details An intercept is added unless the formula contains a special removing it, e.g. time(0)
Expand All @@ -203,6 +220,7 @@ getSpecialFormula = function(f, special) {
}
}


dropSpecial = function(f, special) {
assert_that(is.scalar(special))
tt = terms(f, specials = special)
Expand Down
36 changes: 30 additions & 6 deletions R/meta-method.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ setClass(
slots = c(method = 'lcMethod')
)


#' @exportS3Method base::as.character
as.character.lcMetaMethod = function(x, ...) {
c(
sprintf('%s encapsulating:', class(x)[1]),
Expand All @@ -28,7 +30,8 @@ as.character.lcMetaMethod = function(x, ...) {
)
}

#' @export

#' @exportS3Method stats::getCall
getCall.lcMetaMethod = function(x, ...) {
do.call(
call,
Expand All @@ -42,6 +45,7 @@ getCall.lcMetaMethod = function(x, ...) {
)
}


#' @export
#' @rdname interface-metaMethods
setMethod('compose', 'lcMetaMethod', function(method, envir = NULL) {
Expand All @@ -50,6 +54,7 @@ setMethod('compose', 'lcMetaMethod', function(method, envir = NULL) {
newMethod
})


#' @export
#' @rdname interface-metaMethods
setMethod('getLcMethod', 'lcMetaMethod', function(object, ...) {
Expand All @@ -60,57 +65,76 @@ setMethod('getLcMethod', 'lcMetaMethod', function(object, ...) {
object@method
})


#' @export
#' @rdname interface-metaMethods
setMethod('getName', 'lcMetaMethod', function(object, ...) getName(getLcMethod(object), ...))
setMethod('getName', 'lcMetaMethod',
function(object, ...) getName(getLcMethod(object), ...)
)


#' @export
#' @rdname interface-metaMethods
setMethod('getShortName', 'lcMetaMethod', function(object, ...) getShortName(getLcMethod(object), ...))
setMethod('getShortName', 'lcMetaMethod',
function(object, ...) getShortName(getLcMethod(object), ...)
)


#' @export
#' @rdname interface-metaMethods
setMethod('idVariable', 'lcMetaMethod', function(object, ...) idVariable(getLcMethod(object), ...))


#' @export
#' @rdname interface-metaMethods
setMethod('preFit', 'lcMetaMethod', function(method, data, envir, verbose) {
preFit(getLcMethod(method), data = data, envir = envir, verbose = verbose)
})


#' @export
#' @rdname interface-metaMethods
setMethod('prepareData', 'lcMetaMethod', function(method, data, verbose) {
prepareData(getLcMethod(method), data = data, verbose = verbose)
})


#' @export
#' @rdname interface-metaMethods
setMethod('fit', 'lcMetaMethod', function(method, data, envir, verbose) {
fit(getLcMethod(method), data = data, envir = envir, verbose = verbose)
})


#' @export
#' @rdname interface-metaMethods
setMethod('postFit', 'lcMetaMethod', function(method, data, model, envir, verbose) {
postFit(getLcMethod(method), data = data, model = model, envir = envir, verbose = verbose)
})


#' @export
#' @rdname interface-metaMethods
setMethod('responseVariable', 'lcMetaMethod', function(object, ...) responseVariable(getLcMethod(object), ...))
setMethod('responseVariable', 'lcMetaMethod',
function(object, ...) responseVariable(getLcMethod(object), ...)
)


#' @export
#' @rdname interface-metaMethods
setMethod('timeVariable', 'lcMetaMethod', function(object, ...) timeVariable(getLcMethod(object), ...))
setMethod('timeVariable', 'lcMetaMethod',
function(object, ...) timeVariable(getLcMethod(object), ...)
)


#' @export
#' @rdname interface-metaMethods
setMethod('validate', 'lcMetaMethod', function(method, data, envir = NULL, ...) {
validate(getLcMethod(method), data = data, envir = envir, ...)
})

#' @export

#' @exportS3Method stats::update
#' @rdname interface-metaMethods
#' @inheritParams update.lcMethod
update.lcMetaMethod = function(object, ...) {
Expand Down
Loading

0 comments on commit 2db0782

Please sign in to comment.