From 673c5371815287f6c35ebcb072b658981510c981 Mon Sep 17 00:00:00 2001 From: "Adam B. Smith" Date: Tue, 22 Aug 2023 22:19:40 -0500 Subject: [PATCH] Fix issue in statisfactory.r for CRAN --- DESCRIPTION | 6 ++--- NEWS.md | 4 +++ R/makeFormulae.r | 39 +++++++++++++----------------- R/statisfactory.r | 3 ++- man/dot-removeVerbotenVariables.Rd | 20 --------------- man/makeFormulae.Rd | 4 +-- man/statisfactory.Rd | 8 ++++++ 7 files changed, 36 insertions(+), 48 deletions(-) delete mode 100644 man/dot-removeVerbotenVariables.Rd diff --git a/DESCRIPTION b/DESCRIPTION index e268bf3..a1a63a1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: statisfactory Type: Package Title: Statistical and Geometrical Tools -Version: 1.0.3 -Date: 2022-12-17 +Version: 1.0.4 +Date: 2023-08-21 Authors@R: c( person( @@ -30,4 +30,4 @@ LazyData: true LazyLoad: yes URL: https://github.com/adamlilith/statisfactory Encoding: UTF-8 -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 diff --git a/NEWS.md b/NEWS.md index 7f5491e..b76d906 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +statisfactory 1.0.4 (2023-08-21) +=========== +o Fixed issue in `statisfactory.r` for CRAN + statisfactory 1.0.3 =========== o Added fuzzyJaccard() diff --git a/R/makeFormulae.r b/R/makeFormulae.r index d86d16d..559c752 100644 --- a/R/makeFormulae.r +++ b/R/makeFormulae.r @@ -8,7 +8,7 @@ #' @param linearOnly Logical, if \code{TRUE} (default) then models with only linear terms are included in final set (plus other kinds of models if desired). #' @param quad Logical, if \code{TRUE} (default), then include quadratic terms. #' @param ia Logical, if \code{TRUE} (default), then include 2-way interaction terms. -#' @param verboten Character list of terms that should not appear in the models. Ignored if \code{NULL} (default). Note that using this argument only makes sense if interaction or quadratic terms are specified (if you don't a particular term to appear anywhere in the model it will be faster to remove it from \code{formula}). +#' @param verboten Character vector of terms that should not appear in the models. Ignored if \code{NULL} (default). Note that using this argument only makes sense if interaction or quadratic terms are specified (if you don't a particular term to appear anywhere in the model it will be faster to remove it from \code{formula}). #' @param verbotenCombos List of lists, used to specify specific combinations of terms that should not occur together. See section \emph{Details} below. Ignored if \code{NULL} (default). #' @param minTerms Either a positive integer representing the minimum number of terms required to be in a model, \emph{or} \code{NULL} (default) in which case the smallest model can have just one term. #' @param maxTerms Either a positive integer representing the maximum number of terms allowed to be in a model, \emph{or} \code{NULL} (default) in which case there is no practical limit on the number of terms in a model. @@ -44,17 +44,17 @@ #' @export makeFormulae <- function( formula, - intercept=TRUE, - interceptOnly=TRUE, - linearOnly=TRUE, - quad=TRUE, - ia=TRUE, - verboten=FALSE, - verbotenCombos=NULL, - minTerms=NULL, - maxTerms=NULL, - returnFx=stats::as.formula, - verbose=FALSE + intercept = TRUE, + interceptOnly = TRUE, + linearOnly = TRUE, + quad = TRUE, + ia = TRUE, + verboten = NULL, + verbotenCombos = NULL, + minTerms = NULL, + maxTerms = NULL, + returnFx = stats::as.formula, + verbose = FALSE ) { # get response and predictor(s) @@ -369,11 +369,13 @@ makeFormulae <- function( #' Remove formula with unwanted terms. #' -#' This function takes as an argument a list of character strings representing formulae and returns a potentially shortened list without formulae containing a certain term. -#' @param forms List of characters each representing a formula. +#' This function takes as an argument a vector of character strings representing formulae and returns a potentially shortened list without formulae containing a certain term. +#' +#' @param forms Vector of characters each representing a formula. #' @param verboten Either \code{NULL} (default) in which case \code{forms} is returned without any manipulation. Alternatively, this is a character list of terms that are not allowed to appear in any model in \code{forms}. Models with these terms are removed from \code{forms}. Note that the order of variables in interaction terms does not matter (e.g., \code{x1:x2} will cause the removal of models with this term verbatim as well as \code{x2:x1}). All possible permutations of three-way interaction terms are treated similarly. #' @return A list of character elements representing formulae. #' @keywords internal +#' @noRd .removeVerbotenVariables <- compiler::cmpfun(function( forms, verboten @@ -407,13 +409,10 @@ makeFormulae <- function( # remove formulae with undesired term(s) removeThese <- numeric() for (countModel in seq_along(forms)) { - if (any(forms[[countModel]] %in% verboten)) removeThese <- c(removeThese, countModel) - } if (length(removeThese) > 0) forms <- forms[-removeThese] - forms }) @@ -517,7 +516,7 @@ makeFormulae <- function( ) { formList <- lapply(formList, FUN=function(x) sort(unique(x))) - numTerms <- unlist(lapply(formList, length)) + numTerms <- sapply(formList, length) keep <- list() @@ -525,13 +524,9 @@ makeFormulae <- function( listTheseTerms <- formList[which(numTerms==thisTerms)] listTheseTerms <- if (thisTerms==1) { matrix(sapply(listTheseTerms, paste), nrow=1) } else { sapply(listTheseTerms, paste) } - newTerms <- rep('eq', ncol(listTheseTerms)) - for (countRow in 1:nrow(listTheseTerms)) newTerms <- paste(newTerms, listTheseTerms[countRow, ]) - uniqueTerms <- unique(listTheseTerms, MARGIN=2) - for (countCol in 1:ncol(uniqueTerms)) keep[[length(keep) + 1]] <- c(uniqueTerms[ , countCol]) } diff --git a/R/statisfactory.r b/R/statisfactory.r index 78d4c1e..ccd29c7 100644 --- a/R/statisfactory.r +++ b/R/statisfactory.r @@ -43,5 +43,6 @@ #' @docType package #' @author Adam B. Smith #' @name statisfactory -#' @keywords internal +#' @keywords internal +"_PACKAGE" NULL diff --git a/man/dot-removeVerbotenVariables.Rd b/man/dot-removeVerbotenVariables.Rd deleted file mode 100644 index 1d7648a..0000000 --- a/man/dot-removeVerbotenVariables.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/makeFormulae.r -\name{.removeVerbotenVariables} -\alias{.removeVerbotenVariables} -\title{Remove formula with unwanted terms.} -\usage{ -.removeVerbotenVariables(forms, verboten) -} -\arguments{ -\item{forms}{List of characters each representing a formula.} - -\item{verboten}{Either \code{NULL} (default) in which case \code{forms} is returned without any manipulation. Alternatively, this is a character list of terms that are not allowed to appear in any model in \code{forms}. Models with these terms are removed from \code{forms}. Note that the order of variables in interaction terms does not matter (e.g., \code{x1:x2} will cause the removal of models with this term verbatim as well as \code{x2:x1}). All possible permutations of three-way interaction terms are treated similarly.} -} -\value{ -A list of character elements representing formulae. -} -\description{ -This function takes as an argument a list of character strings representing formulae and returns a potentially shortened list without formulae containing a certain term. -} -\keyword{internal} diff --git a/man/makeFormulae.Rd b/man/makeFormulae.Rd index ca4dfb0..3d7b38e 100644 --- a/man/makeFormulae.Rd +++ b/man/makeFormulae.Rd @@ -11,7 +11,7 @@ makeFormulae( linearOnly = TRUE, quad = TRUE, ia = TRUE, - verboten = FALSE, + verboten = NULL, verbotenCombos = NULL, minTerms = NULL, maxTerms = NULL, @@ -32,7 +32,7 @@ makeFormulae( \item{ia}{Logical, if \code{TRUE} (default), then include 2-way interaction terms.} -\item{verboten}{Character list of terms that should not appear in the models. Ignored if \code{NULL} (default). Note that using this argument only makes sense if interaction or quadratic terms are specified (if you don't a particular term to appear anywhere in the model it will be faster to remove it from \code{formula}).} +\item{verboten}{Character vector of terms that should not appear in the models. Ignored if \code{NULL} (default). Note that using this argument only makes sense if interaction or quadratic terms are specified (if you don't a particular term to appear anywhere in the model it will be faster to remove it from \code{formula}).} \item{verbotenCombos}{List of lists, used to specify specific combinations of terms that should not occur together. See section \emph{Details} below. Ignored if \code{NULL} (default).} diff --git a/man/statisfactory.Rd b/man/statisfactory.Rd index 499d586..a708727 100644 --- a/man/statisfactory.Rd +++ b/man/statisfactory.Rd @@ -3,6 +3,7 @@ \docType{package} \name{statisfactory} \alias{statisfactory} +\alias{statisfactory-package} \title{statisfactory: Statistical and Geometrical Tools} \description{ This package contains various statistical tools and helper functions. @@ -63,6 +64,13 @@ Create an issue on \href{https://github.com/adamlilith/statisfactory/issues}{Git \code{\link{hist2d}}: Two-dimensional histogram \cr } +\seealso{ +Useful links: +\itemize{ + \item \url{https://github.com/adamlilith/statisfactory} +} + +} \author{ Adam B. Smith }