From b2afe00c8e42b11b59dd5bc99c6cfd26cfbb6099 Mon Sep 17 00:00:00 2001 From: Andreas Busjahn Date: Thu, 1 Aug 2024 21:09:23 +0200 Subject: [PATCH] help ColSeeker extended ksnormal returnes named numeric --- R/basefunctions.R | 12 ++++++++---- R/tests.R | 2 ++ man/ColSeeker.Rd | 9 +++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/R/basefunctions.R b/R/basefunctions.R index 8732e91..f3b1393 100644 --- a/R/basefunctions.R +++ b/R/basefunctions.R @@ -209,6 +209,7 @@ formatP <- function(pIn, ndigits = 3, textout = TRUE, pretext = FALSE, #' FindVars(varnames = c("^c", "g"), allnames = colnames(mtcars), exclude = "r") ## rawdata <- mtcars ## FindVars(varnames = c("^c", "g")) + FindVars <- function(varnames, allnames = colnames(rawdata), exact = FALSE, exclude = NA, casesensitive = TRUE, fixed = FALSE, return_symbols=FALSE) { @@ -270,7 +271,7 @@ FindVars <- function(varnames, allnames = colnames(rawdata), } -#' Find numeric index and names of columns based on type and patterns +#' Find numeric index and names of columns based on class(es) and patterns #' #' \code{ColSeeker} looks up colnames (by default for tibble rawdata) #' based on type and parts of names, using regular expressions. @@ -286,12 +287,15 @@ FindVars <- function(varnames, allnames = colnames(rawdata), #' @param returnclass Logical if classes should be included in output #' #' @export -#' @return A list with index, names, and backticked names, optionally the classes as well +#' @return A list with index, names, backticked names, and count; optionally the classes as well #' @examples #' ColSeeker(data = mtcars, namepattern = c("^c", "g")) #' ColSeeker(data = mtcars, namepattern = c("^c", "g"), exclude = "r") -## rawdata <- mtcars -## ColSeeker(namepattern = c("^c", "g"), varclass="numeric") +#' assign("rawdata", mtcars) +#' ColSeeker(namepattern = c("^c", "g"), varclass="numeric") +#' num_int_data <- data.frame(num1=rnorm(10), num2=runif(10), int1=1:10, int2=11:20) +#' ColSeeker(num_int_data, varclass="numeric") # integers are not found +#' ColSeeker(num_int_data, varclass=c("numeric","integer")) ColSeeker <- function(data=rawdata, namepattern = '.', varclass = NULL, diff --git a/R/tests.R b/R/tests.R index 1e5b0c0..d7febdd 100644 --- a/R/tests.R +++ b/R/tests.R @@ -202,6 +202,7 @@ ksnormal <- function(x, lillie=TRUE) { if(lillie){ assign("ksout", nortest::lillie.test(x)$p.value) + names(ksout) <- "p_Normal_Lilliefors" } else{ suppressWarnings( assign("ksout", @@ -209,6 +210,7 @@ ksnormal <- function(x, lillie=TRUE) { sd(x, na.rm = TRUE), exact = FALSE )$p.value)) + names(ksout) <- "p_Normal_KS" } }else{ diff --git a/man/ColSeeker.Rd b/man/ColSeeker.Rd index 0830e84..99ee833 100644 --- a/man/ColSeeker.Rd +++ b/man/ColSeeker.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/basefunctions.R \name{ColSeeker} \alias{ColSeeker} -\title{Find numeric index and names of columns based on type and patterns} +\title{Find numeric index and names of columns based on class(es) and patterns} \usage{ ColSeeker( data = rawdata, @@ -30,7 +30,7 @@ ColSeeker( \item{returnclass}{Logical if classes should be included in output} } \value{ -A list with index, names, and backticked names, optionally the classes as well +A list with index, names, backticked names, and count; optionally the classes as well } \description{ \code{ColSeeker} looks up colnames (by default for tibble rawdata) @@ -41,4 +41,9 @@ Exclusion rules may be specified as well. \examples{ ColSeeker(data = mtcars, namepattern = c("^c", "g")) ColSeeker(data = mtcars, namepattern = c("^c", "g"), exclude = "r") +assign("rawdata", mtcars) +ColSeeker(namepattern = c("^c", "g"), varclass="numeric") +num_int_data <- data.frame(num1=rnorm(10), num2=runif(10), int1=1:10, int2=11:20) +ColSeeker(num_int_data, varclass="numeric") # integers are not found +ColSeeker(num_int_data, varclass=c("numeric","integer")) }