From 7544f08a9039a491d7f2d08dd253a713eea38674 Mon Sep 17 00:00:00 2001 From: Sander Devisscher Date: Tue, 30 Apr 2024 09:47:54 +0200 Subject: [PATCH] fix remaining errors & warnings #7 --- DESCRIPTION | 3 ++- R/check.R | 2 +- R/colcompare.R | 10 ++++++---- man/colcompare.Rd | 4 +++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f31705a..6b5507a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,4 +11,5 @@ Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 Imports: dplyr (>= 1.1.4), - magrittr (>= 2.0.3) + magrittr (>= 2.0.3), + rlang (>= 1.1.3) diff --git a/R/check.R b/R/check.R index 4611414..46a952f 100644 --- a/R/check.R +++ b/R/check.R @@ -12,4 +12,4 @@ #' 0 = object doesn't exist in enviroment -check <- function(x){tryCatch(if(class(x) == 'logical') 1 else 1, error=function(e) 0)} +check <- function(x){tryCatch(if(is.logical(class(x))) 1 else 1, error=function(e) 0)} diff --git a/R/colcompare.R b/R/colcompare.R index 7ad8eb5..0465af8 100644 --- a/R/colcompare.R +++ b/R/colcompare.R @@ -13,6 +13,7 @@ #' present in y and not in x. #' #' @examples +#' \dontrun{ #' # create example dataframes #' super_sleepers <- data.frame(rating=1:4, #' animal=c('koala', 'hedgehog', 'sloth', 'panda'), @@ -22,9 +23,10 @@ #' super_actives <- data.frame(rating=1:4, #' animal=c('kangeroo', 'wolf', 'jaguar', 'tiger'), #' country=c('Australia', 'Italy', 'Peru', 'China'), -#' avg_active_hours=c(16, 15, 8, 10))) +#' avg_active_hours=c(16, 15, 8, 10)) #' #' colcompare(super_sleepers, super_actives) +#' } #' #' @importFrom magrittr %>% @@ -47,7 +49,7 @@ colcompare <- function(x, y){ test_xANDy <- test_xANDy$test_xANDy if(check(test_xANDy) == 1){ - if(!is_empty(test_xANDy)){ + if(!rlang::is_empty(test_xANDy)){ error <- paste0("Kolommen met verschillende schrijfwijze: \n", test_xANDy) writeLines(error) @@ -60,7 +62,7 @@ colcompare <- function(x, y){ test_xiny <- test_xiny$test_xiny if(check(test_xiny)==1){ - if(!is_empty(test_xiny)){ + if(!rlang::is_empty(test_xiny)){ test_xiny <- paste(test_xiny, collapse = ", \n") error <- paste0("Kolommen uit x die niet in y voorkomen: \n", test_xiny) writeLines(error) @@ -74,7 +76,7 @@ colcompare <- function(x, y){ test_yinx <- test_yinx$test_yinx if(check(test_yinx)==1){ - if(!is_empty(test_yinx)){ + if(!rlang::is_empty(test_yinx)){ test_yinx <- paste(test_yinx, collapse = ", \n") error <- paste0("Kolommen uit y die niet in x voorkomen: ", test_yinx) writeLines(error) diff --git a/man/colcompare.Rd b/man/colcompare.Rd index 89266ac..24ec9f3 100644 --- a/man/colcompare.Rd +++ b/man/colcompare.Rd @@ -19,6 +19,7 @@ present in y and not in x. A simple function to list the difference in column names in 2 datasets. } \examples{ +\dontrun{ # create example dataframes super_sleepers <- data.frame(rating=1:4, animal=c('koala', 'hedgehog', 'sloth', 'panda'), @@ -28,9 +29,10 @@ avg_sleep_hours=c(21, 18, 17, 10)) super_actives <- data.frame(rating=1:4, animal=c('kangeroo', 'wolf', 'jaguar', 'tiger'), country=c('Australia', 'Italy', 'Peru', 'China'), -avg_active_hours=c(16, 15, 8, 10))) +avg_active_hours=c(16, 15, 8, 10)) colcompare(super_sleepers, super_actives) +} } \author{