From 6140cae350998ffd1fdcb37c72d5584f04e5c606 Mon Sep 17 00:00:00 2001 From: laresbernardo Date: Thu, 12 Sep 2024 16:44:36 +0200 Subject: [PATCH] CRAN v5.2.9 --- DESCRIPTION | 6 +++--- R/audio.R | 4 ++-- R/robyn.R | 6 ++++-- R/scrabble.R | 36 ++++++++++++++++++++---------------- R/trees.R | 6 +++--- man/scrabble.Rd | 2 +- man/tree_var.Rd | 16 ---------------- 7 files changed, 33 insertions(+), 43 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 80ce45a98..47f1dd2fe 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,14 +1,14 @@ Package: lares Type: Package Title: Analytics & Machine Learning Sidekick -Version: 5.2.8.9006 +Version: 5.2.9 Authors@R: c( person("Bernardo", "Lares", , "laresbernardo@gmail.com", c("aut", "cre"))) Maintainer: Bernardo Lares Description: Auxiliary package for better/faster analytics, visualization, data mining, and machine learning tasks. With a wide variety of family functions, like Machine Learning, Data Wrangling, - Exploratory, API, and Scrapper, it helps the analyst or data scientist to get quick and robust - results, without the need of repetitive coding or extensive R programming skills. + MMM, Exploratory, API, and Scrapper, it helps the analyst or data scientist to get quick and + robust results, without the need of repetitive coding or advanced R programming skills. Depends: R (>= 3.5.0) Imports: diff --git a/R/audio.R b/R/audio.R index c399ae822..558e62b66 100644 --- a/R/audio.R +++ b/R/audio.R @@ -129,7 +129,7 @@ get_mp3 <- function(id, if (open) { if (file.exists(mp3_file)) { message("Opening file: ", mp3_file) - browseURL(mp3_file) + browseURL(mp3_file) } else { warning("Can't open file; possibly due to strange characters in title: ", mp3_file) } @@ -139,7 +139,7 @@ get_mp3 <- function(id, if (file.exists(mp3_file)) { message("Deleting file: ", mp3_file) if (open) Sys.sleep(5) - file.remove(mp3_file) + file.remove(mp3_file) } else { warning("Can't delete file; possibly due to strange characters in title: ", mp3_file) } diff --git a/R/robyn.R b/R/robyn.R index a6e7acc88..e576c7856 100644 --- a/R/robyn.R +++ b/R/robyn.R @@ -592,8 +592,10 @@ robyn_performance <- function( if (carryovers) { try_require("Robyn") carrov <- robyn_immcarr( - InputCollect, OutputCollect, solID = solID, - start_date = start_date, end_date = end_date, ...) %>% + InputCollect, OutputCollect, + solID = solID, + start_date = start_date, end_date = end_date, ... + ) %>% filter(.data$type == "Carryover") mean_carryovers <- data.frame( channel = carrov$rn, diff --git a/R/scrabble.R b/R/scrabble.R index 3812b076a..f0ba9228b 100644 --- a/R/scrabble.R +++ b/R/scrabble.R @@ -108,7 +108,7 @@ scrabble_score <- function(words, scores.df) { #' @family Scrabble #' @param lang Character. Any of "en","es" or "chars". Set to NULL #' if you wish to skip this step (and use \code{words} parameter in -#' \code{scrabble_words()} instead). The "chars" parameter will +#' \code{scrabble_words()} instead). The "chars" parameter will #' score the number of characters a word has. #' @return data.frame with tiles and scores for each alphabet letter. #' @examples @@ -133,15 +133,19 @@ scrabble_points <- function(lang) { tolower(LETTERS)[1:14], intToUtf8(241), tolower(LETTERS)[15:length(LETTERS)] ), - scores = c(1, 3, 2, 2, 1, 4, 3, 4, 1, 8, 10, 1, 3, 1, - 8, 1, 3, 5, 1, 1, 1, 2, 4, 10, 10, 5, 10) + scores = c( + 1, 3, 2, 2, 1, 4, 3, 4, 1, 8, 10, 1, 3, 1, + 8, 1, 3, 5, 1, 1, 1, 2, 4, 10, 10, 5, 10 + ) ) } if (lang == "en") { scores <- data.frame( tiles = tolower(LETTERS), - scores = c(1, 4, 4, 2, 1, 4, 3, 3, 1, 10, 5, 2, 4, - 2, 1, 4, 10, 1, 1, 1, 2, 5, 4, 8, 3, 10) + scores = c( + 1, 4, 4, 2, 1, 4, 3, 3, 1, 10, 5, 2, 4, + 2, 1, 4, 10, 1, 1, 1, 2, 5, 4, 8, 3, 10 + ) ) } if (lang %in% c("chars", "unique")) { @@ -370,17 +374,17 @@ scrabble_words <- function(tiles = "", } # Exclude letters from positions (Wordle) if (exclude_here[1] != "") { - for (eh in exclude_here) { - pos_tiles <- str_split_merge(tolower(eh)) - for (i in seq_along(pos_tiles)) { - these <- str_split(pos_tiles, "\\|")[i][[1]] - if (!any(these %in% letters)) next - located <- stringr::str_locate_all(words, pos_tiles[i]) - these <- !unlist(lapply(located, function(x) sum(x[, 1] == i) > 0)) - words <- words[these] - .temp_print(length(words)) + for (eh in exclude_here) { + pos_tiles <- str_split_merge(tolower(eh)) + for (i in seq_along(pos_tiles)) { + these <- str_split(pos_tiles, "\\|")[i][[1]] + if (!any(these %in% letters)) next + located <- stringr::str_locate_all(words, pos_tiles[i]) + these <- !unlist(lapply(located, function(x) sum(x[, 1] == i) > 0)) + words <- words[these] + .temp_print(length(words)) + } } - } } .temp_print(length(words), last = TRUE) @@ -391,7 +395,7 @@ scrabble_words <- function(tiles = "", mutate(length = str_length(.data$word)) %>% arrange(desc(.data$scores), desc(.data$length)) } else { - done <- scrabble_score(words, scores.df) + done <- scrabble_score(words, scores.df) } if (sum(done$scores) == 0) done$scores <- NULL return(as_tibble(done)) diff --git a/R/trees.R b/R/trees.R index 2cdd81ec3..ceea1d5f9 100644 --- a/R/trees.R +++ b/R/trees.R @@ -7,9 +7,9 @@ #' @family Exploratory #' @family Visualization #' @inheritParams h2o_automl -#' @inherit rpart::rpart -#' @inherit rpart::rpart.control -#' @inherit rpart.plot::rpart.plot +#' @inheritParams rpart::rpart +#' @inheritParams rpart::rpart.control +#' @inheritParams rpart.plot::rpart.plot #' @param df Data frame #' @param max Integer. Maximal depth of the tree. #' @param min Integer. The minimum number of observations that must diff --git a/man/scrabble.Rd b/man/scrabble.Rd index 878fe5f9b..569e5273a 100644 --- a/man/scrabble.Rd +++ b/man/scrabble.Rd @@ -46,7 +46,7 @@ letter of the alphabet and "scores" for each letter's score.} \item{lang}{Character. Any of "en","es" or "chars". Set to NULL if you wish to skip this step (and use \code{words} parameter in -\code{scrabble_words()} instead). The "chars" parameter will +\code{scrabble_words()} instead). The "chars" parameter will score the number of characters a word has.} \item{tiles}{Character. The letters you wish to consider.} diff --git a/man/tree_var.Rd b/man/tree_var.Rd index 528c378c9..f6aefbe20 100644 --- a/man/tree_var.Rd +++ b/man/tree_var.Rd @@ -83,12 +83,6 @@ predictions, performance metrics, and interpret auxiliary text. Fit and plot a \code{rpart} model for exploratory purposes using \code{rpart} and \code{rpart.plot} libraries. } -\details{ -This differs from the \code{tree} function in S mainly in its handling - of surrogate variables. In most details it follows Breiman - \emph{et. al} (1984) quite closely. \R package \pkg{tree} provides a - re-implementation of \code{tree}. -} \examples{ data(dft) # Regression Tree @@ -101,11 +95,6 @@ tree_var(dft, Survived_TRUE, explain = FALSE, cex = 0.8)$plot() # Multiclass tree tree_var(dft[, c("Pclass", "Fare", "Age")], Pclass, ohse = FALSE)$plot() } -\references{ -Breiman L., Friedman J. H., Olshen R. A., and Stone, C. J. (1984) - \emph{Classification and Regression Trees.} - Wadsworth. -} \seealso{ Other Exploratory: \code{\link{corr_cross}()}, @@ -134,10 +123,5 @@ Other Visualization: \code{\link{plot_survey}()}, \code{\link{plot_timeline}()} } -\author{ -Stephen Milborrow, borrowing heavily from the \code{\link{rpart}} - package by Terry M. Therneau and Beth Atkinson, - and the R port of that package by Brian Ripley. -} \concept{Exploratory} \concept{Visualization}