extras/PackageMaintenance.R

# Copyright 2021 Observational Health Data Sciences and Informatics
#
# This file is part of CohortMethod
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Manually delete package from library. Avoids "Already in use" message when rebuilding
unloadNamespace("CohortMethod")
.rs.restartR()
folder <- system.file(package = "CohortMethod")
folder
unlink(folder, recursive = TRUE, force = TRUE)
file.exists(folder)

# Format and check code:
OhdsiRTools::formatRFolder()
OhdsiRTools::checkUsagePackage("CohortMethod")
OhdsiRTools::updateCopyrightYearFolder()
OhdsiRTools::findNonAsciiStringsInFolder()
devtools::spell_check()

# Create manual and vignettes:
unlink("extras/CohortMethod.pdf")
shell("R CMD Rd2pdf ./ --output=extras/CohortMethod.pdf")

rmarkdown::render("vignettes/SingleStudies.Rmd",
                  output_file = "../inst/doc/SingleStudies.pdf",
                  rmarkdown::pdf_document(latex_engine = "pdflatex",
                                          toc = TRUE,
                                          number_sections = TRUE))
unlink("inst/doc/SingleStudies.tex")

rmarkdown::render("vignettes/MultipleAnalyses.Rmd",
                  output_file = "../inst/doc/MultipleAnalyses.pdf",
                  rmarkdown::pdf_document(latex_engine = "pdflatex",
                                          toc = TRUE,
                                          number_sections = TRUE))
unlink("inst/doc/MultipleAnalyses.tex")

pkgdown::build_site()
OhdsiRTools::fixHadesLogo()

# Create arg functions:
rCode <- c("# This file has been autogenerated. Do not change by hand. ")
rCode <- ParallelLogger::createArgFunction("getDbCohortMethodData",
                                           excludeArgs = c("connectionDetails",
                                                           "cdmDatabaseSchema",
                                                           "oracleTempSchema",
                                                           "tempEmulationSchema",
                                                           "exposureDatabaseSchema",
                                                           "exposureTable",
                                                           "outcomeDatabaseSchema",
                                                           "outcomeTable",
                                                           "cdmVersion",
                                                           "targetId",
                                                           "comparatorId",
                                                           "outcomeIds"),
                                           rCode = rCode)
rCode <- ParallelLogger::createArgFunction("createStudyPopulation",
                                           excludeArgs = c("cohortMethodData",
                                                           "population",
                                                           "outcomeId"),
                                           rCode = rCode)
rCode <- ParallelLogger::createArgFunction("createPs",
                                           excludeArgs = c("cohortMethodData", "population"),
                                           rCode = rCode)
rCode <- ParallelLogger::createArgFunction("trimByPs", excludeArgs = c("population"), rCode = rCode)
rCode <- ParallelLogger::createArgFunction("trimByPsToEquipoise",
                                           excludeArgs = c("population"),
                                           rCode = rCode)
rCode <- ParallelLogger::createArgFunction("trimByIptw", excludeArgs = c("population"), rCode = rCode)
rCode <- ParallelLogger::createArgFunction("matchOnPs", excludeArgs = c("population"), rCode = rCode)
rCode <- ParallelLogger::createArgFunction("matchOnPsAndCovariates",
                                           excludeArgs = c("population", "cohortMethodData"),
                                           rCode = rCode)
rCode <- ParallelLogger::createArgFunction("stratifyByPs",
                                           excludeArgs = c("population"),
                                           rCode = rCode)
rCode <- ParallelLogger::createArgFunction("stratifyByPsAndCovariates",
                                           excludeArgs = c("population", "cohortMethodData"),
                                           rCode = rCode)
rCode <- ParallelLogger::createArgFunction("fitOutcomeModel",
                                           excludeArgs = c("population", "cohortMethodData"),
                                           rCode = rCode)
writeLines(rCode, "r/CreateArgFunctions.R")
OhdsiRTools::formatRFile("r/CreateArgFunctions.R")
escott12/CohortMethod documentation built on Dec. 20, 2021, 6:37 a.m.