From c6e48f2abeb986a2acbc433a17f3d995d1059b49 Mon Sep 17 00:00:00 2001 From: lilyclements Date: Mon, 2 Dec 2024 17:11:05 +0000 Subject: [PATCH] updating R packages to 18.10.2024 --- DESCRIPTION | 1 + NAMESPACE | 6 + R/get_default_significant_figures.R | 3 +- ..._to_ggwalter_lieth.R => group_functions.R} | 195 ++++++++++++++++-- R/iscontainPartialValueLabel.R | 23 +++ R/package_check.R | 100 ++++----- man/cbind_unique.Rd | 2 +- man/check_github_repo.Rd | 39 ++++ man/check_graph.Rd | 2 +- man/convert_to_list.Rd | 2 +- man/frac10.Rd | 27 +++ man/getExample.Rd | 2 +- man/getRowHeadersWithText.Rd | 11 +- man/get_data_book_output_object_names.Rd | 2 +- man/get_data_book_scalar_names.Rd | 37 ++++ man/get_vignette.Rd | 2 +- man/is.containPartialValueLabel.Rd | 22 ++ man/monitor_memory.Rd | 19 ++ man/package_check.Rd | 37 ++-- man/process_html_object.Rd | 2 +- man/read_corpora.Rd | 2 +- man/time_operation.Rd | 22 ++ man/view_graph_object.Rd | 2 +- man/view_html_object.Rd | 2 +- man/view_object.Rd | 2 +- man/view_object_data.Rd | 2 +- man/view_text_object.Rd | 2 +- 27 files changed, 475 insertions(+), 93 deletions(-) rename R/{read_corpora_to_ggwalter_lieth.R => group_functions.R} (78%) create mode 100644 R/iscontainPartialValueLabel.R create mode 100644 man/check_github_repo.Rd create mode 100644 man/frac10.Rd create mode 100644 man/get_data_book_scalar_names.Rd create mode 100644 man/is.containPartialValueLabel.Rd create mode 100644 man/monitor_memory.Rd create mode 100644 man/time_operation.Rd diff --git a/DESCRIPTION b/DESCRIPTION index b38bd43..6c68b33 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,6 +27,7 @@ Imports: magrittr, methods, plyr, + pingr, rlang, sjlabelled, stringr, diff --git a/NAMESPACE b/NAMESPACE index f8fa195..ed330ea 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ export("%>%") export(cancor_coef) export(cbind_unique) +export(check_github_repo) export(check_graph) export(compare_columns) export(consecutive_sum) @@ -11,10 +12,12 @@ export(create_av_packs) export(drop_unused_levels) export(duplicated_cases) export(duplicated_count_index) +export(frac10) export(getExample) export(getRowHeadersWithText) export(get_column_attributes) export(get_data_book_output_object_names) +export(get_data_book_scalar_names) export(get_default_significant_figures) export(get_installed_packages_with_data) export(get_odk_form_names) @@ -24,12 +27,14 @@ export(import_from_ODK) export(in_top_n) export(is.NAvariable) export(is.binary) +export(is.containPartialValueLabel) export(is.containValueLabel) export(is.containVariableLabel) export(is.emptyvariable) export(is.levelscount) export(is.logical.like) export(make_factor) +export(monitor_memory) export(next_default_item) export(package_check) export(process_html_object) @@ -40,6 +45,7 @@ export(slopegraph) export(slopegraph_theme) export(split_items_in_groups) export(summary_sample) +export(time_operation) export(view_graph_object) export(view_html_object) export(view_object) diff --git a/R/get_default_significant_figures.R b/R/get_default_significant_figures.R index bd02be5..026a68c 100644 --- a/R/get_default_significant_figures.R +++ b/R/get_default_significant_figures.R @@ -11,6 +11,7 @@ #' x <- 1:8 #' get_default_significant_figures(x) get_default_significant_figures <- function(data) { - if(is.numeric(data)) return(3) + default_digits <- getOption("digits") + if(is.numeric(data) || is.complex(data)) return(default_digits) else return(NA) } diff --git a/R/read_corpora_to_ggwalter_lieth.R b/R/group_functions.R similarity index 78% rename from R/read_corpora_to_ggwalter_lieth.R rename to R/group_functions.R index 28a7967..1f4a2da 100644 --- a/R/read_corpora_to_ggwalter_lieth.R +++ b/R/group_functions.R @@ -150,7 +150,7 @@ view_graph_object <- function(graph_object){ grid::grid.draw(graph_object) } return(graph_object) - } + } #get a unique temporary file name from the tempdir path @@ -163,7 +163,7 @@ view_graph_object <- function(graph_object){ }else{ print(graph_object) } - grDevices::dev.off() #todo. use graphics.off() which one is better? + dev.off() #todo. use graphics.off() which one is better? #todo. should we use respective package "convenience" functions to save the objects as image files depending on the class names? @@ -312,7 +312,7 @@ check_graph <- function(graph_object){ if (is.null(out)) { out <- tryCatch({ message("Recording plot") - grDevices::recordPlot() + recordPlot() }, error = function(cond) { message("Graph object does not exist:") @@ -331,7 +331,7 @@ check_graph <- function(graph_object){ } return(out) -} +} #' Get Data Book Output Object Names #' @@ -480,14 +480,23 @@ get_vignette <- function (package = NULL, lib.loc = NULL, all = TRUE) #' getRowHeadersWithText(my_data, "column1", "search text", TRUE, FALSE) #' } #' @export -getRowHeadersWithText <- function(data, column, searchText, ignore_case, use_regex) { - if(use_regex){ +getRowHeadersWithText <- function(data, column, searchText, ignore_case, use_regex, match_entire_cell) { + if (use_regex) { + # Adjust the search text to match the entire cell if required + if (match_entire_cell) { + searchText <- paste0("^", searchText, "$") + } # Find the rows that match the search text using regex matchingRows <- stringr::str_detect(data[[column]], stringr::regex(searchText, ignore_case = ignore_case)) - }else if (is.na(searchText)){ + } else if (is.na(searchText)) { matchingRows <- apply(data[, column, drop = FALSE], 1, function(row) any(is.na(row))) - }else{ - matchingRows <- grepl(searchText, data[[column]], ignore.case = ignore_case) + } else { + # Adjust the search text to match the entire cell if required + if (match_entire_cell) { + searchText <- paste0("^", searchText, "$") + } + # Find the rows that match the search text + matchingRows <- grepl(searchText, data[[column]], ignore.case = ignore_case, perl = TRUE) } # Get the row headers where the search text is found rowHeaders <- rownames(data)[matchingRows] @@ -543,15 +552,13 @@ convert_to_list <- function(x) { #' } #' @export getExample <- function (topic, package = NULL, lib.loc = NULL, character.only = TRUE, give.lines = FALSE, local = FALSE, echo = TRUE, verbose = getOption("verbose"), setRNG = FALSE, ask = getOption("example.ask"), prompt.prefix = abbreviate(topic, 6), run.dontrun = FALSE, run.donttest = interactive()) { - index.search < -utils::getFromNamespace("index.search", "utils") - `.getHelpFile` <- utils::getFromNamespace(".getHelpFile", "utils") if (!character.only) { topic <- substitute(topic) if (!is.character(topic)) topic <- deparse(topic)[1L] } pkgpaths <- find.package(package, lib.loc, verbose = verbose) - file <- index.search(topic, pkgpaths, firstOnly = TRUE) + file <- utils:::index.search(topic, pkgpaths, firstOnly = TRUE) if (!length(file)) { warning(gettextf("no help found for %s", sQuote(topic)), domain = NA) @@ -563,7 +570,7 @@ getExample <- function (topic, package = NULL, lib.loc = NULL, character.only = pkgname <- basename(packagePath) lib <- dirname(packagePath) tf <- tempfile("Rex") - tools::Rd2ex(.getHelpFile(file), tf, commentDontrun = !run.dontrun, + tools::Rd2ex(utils:::.getHelpFile(file), tf, commentDontrun = !run.dontrun, commentDonttest = !run.donttest) if (!file.exists(tf)) { if (give.lines) @@ -582,4 +589,166 @@ getExample <- function (topic, package = NULL, lib.loc = NULL, character.only = cat(example_text) } return(example_text) +} + +#' Get Scalar Names from Data Book +#' +#' @description +#' Extracts scalar names from a given list, with the option to exclude specific items, +#' return the names as a list, and provide a label for the list. +#' +#' @param scalar_list A named list from which to extract scalar names. +#' @param excluded_items A character vector of items to exclude from the output. Defaults to an empty vector. +#' @param as_list A logical value indicating whether to return the result as a list. Defaults to `FALSE`. +#' @param list_label A character string specifying the label for the list, if `as_list = TRUE`. +#' +#' @return A character vector of scalar names, or a named list if `as_list = TRUE`. +#' +#' @examples +#' # Extract names excluding specific items +#' get_data_book_scalar_names(list(a = 1, b = 2, c = 3), excluded_items = c("b")) +#' +#' # Return the names as a list with a label +#' get_data_book_scalar_names(list(a = 1, b = 2), as_list = TRUE, list_label = "Scalars") +#' +#' @export +get_data_book_scalar_names <- function(scalar_list, + excluded_items = c(), + as_list = FALSE, + list_label = NULL) { + out = names(scalar_list) + if (length(excluded_items) > 0) { + ex_ind = which(out %in% excluded_items) + if (length(ex_ind) != length(excluded_items)) warning("Some of the excluded_items were not found in the list of calculations") + if (length(ex_ind) > 0) out = out[-ex_ind] + } + if (!as_list) { + return(out) + } + lst = list() + lst[[list_label]] <- out + return(lst) +} + +#' Check GitHub Repository +#' +#' @description +#' Verifies the existence and status of a GitHub repository, including whether it is an R package, +#' and checks if a locally installed package is up-to-date with the latest commit on GitHub. +#' +#' @param owner A character string specifying the GitHub repository owner. Defaults to `NULL`. +#' @param repo A character string specifying the repository name. Defaults to `NULL`. +#' @param url A character string specifying the full GitHub URL of the repository. Defaults to `NULL`. +#' +#' @return An integer status code: +#' \describe{ +#' \item{0}{Package is installed and up-to-date.} +#' \item{1}{Package is installed but not the latest version.} +#' \item{2}{Unable to retrieve the latest commit from GitHub.} +#' \item{3}{Package is installed but not from GitHub.} +#' \item{4}{Repository exists and is an R package.} +#' \item{5}{Repository exists but is not an R package.} +#' \item{6}{Repository does not exist or an error occurred.} +#' } +#' +#' @examples +#' # Check a repository using owner and repo +#' check_github_repo(owner = "hadley", repo = "ggplot2") +#' +#' # Check a repository using a URL +#' check_github_repo(url = "https://github.com/hadley/ggplot2") +#' +#' @export +check_github_repo <- function(owner = NULL, repo = NULL, url = NULL) { + if (!is.null(url)) { + url <- sub(".*github.com/", "", url) + owner <- dirname(url) + repo <- basename(url) + } + if (requireNamespace(repo, quietly = TRUE)) { + local_sha <- packageDescription(repo)$GithubSHA1 + if (!is.null(local_sha)) { + latest_commit <- tryCatch({ + response <- gh::gh("/repos/:owner/:repo/commits", owner = owner, repo = repo, .limit = 1) + response[[1]]$sha + }, error = function(e) { + return(NULL) + }) + if (!is.null(latest_commit)) { + if (local_sha == latest_commit) return(0) + else return(1) + } else return(2) + } else return(3) + } else { + tryCatch({ + response <- gh::gh("/repos/:owner/:repo", owner = owner, repo = repo, verb = "GET", silent = TRUE) + if (response$language == "R") return(4) + else return(5) + }, error = function(e) { + return(6) + }) + } +} + +#' Convert Decimal to Fraction +#' +#' @description +#' Converts a decimal value into a fraction with a specified denominator or common denominators (10, 20, or 100). +#' +#' @param x A numeric value representing the decimal to convert. +#' @param den An integer specifying the denominator for the fraction. (Only for `frac_den`.) +#' +#' @return A character string representing the fraction. +#' +#' @examples +#' # Convert decimals to fractions +#' frac10(0.75) # "8/10" +#' frac20(0.25) # "5/20" +#' frac100(0.123) # "12/100" +#' frac_den(0.333, 3) # "1/3" +#' +#' @export +frac10 <- function(x) { paste0(round(x * 10), "/", 10) } +frac20 <- function(x) { paste0(round(x * 20), "/", 20) } +frac100 <- function(x) { paste0(round(x * 100), "/", 100) } +frac_den <- function(x, den) { paste0(round(x * den), "/", den) } + +#' Monitor Memory Usage +#' +#' @description +#' Monitors and returns the current memory usage in megabytes (MB). +#' +#' @return A numeric value representing the memory usage in MB. +#' +#' @examples +#' # Check memory usage +#' monitor_memory() +#' +#' @export +monitor_memory <- function() { + if (.Platform$OS.type == "windows") { + mem_used <- memory.size() + } else { + mem_used <- sum(gc()[, "used"]) / 1024 + } + return(mem_used) +} + +#' Time an Operation +#' +#' @description +#' Measures and prints the time taken to execute an expression. +#' +#' @param expr An R expression to evaluate and time. +#' +#' @return Prints the time taken for the operation. +#' +#' @examples +#' # Time a simple operation +#' time_operation({ Sys.sleep(1); mean(1:100) }) +#' +#' @export +time_operation <- function(expr) { + timing <- system.time(expr) + print(timing) } \ No newline at end of file diff --git a/R/iscontainPartialValueLabel.R b/R/iscontainPartialValueLabel.R new file mode 100644 index 0000000..e96a672 --- /dev/null +++ b/R/iscontainPartialValueLabel.R @@ -0,0 +1,23 @@ +#' Check for Partial Value Labels +#' +#' @description +#' Checks if the variable contains partial value labels (some values labeled, others not). +#' +#' @param x A variable to check for partial value labels. +#' +#' @return A logical value. Returns `TRUE` if the variable contains partial value labels, otherwise `FALSE`. +#' +#' @examples +#' # Example with partially labeled variable +#' #is.containPartialValueLabel(x) +#' +#' @export +is.containPartialValueLabel <- function(x) { + if (is.containValueLabel(x)) { + levelCounts <- table(x) + return(!all(x[!is.na(x)] %in% attr(x, labels_label)) && + sum(levelCounts == 0) == 0) + } else { + return(FALSE) + } +} diff --git a/R/package_check.R b/R/package_check.R index b27250a..f392b8a 100644 --- a/R/package_check.R +++ b/R/package_check.R @@ -1,61 +1,67 @@ - #' Package Check - +#' #' @description -#' This function checks the status of a specified package in the current R environment. It verifies whether the package is installed, and if so, it compares the installed version with the latest version available online. - +#' This function checks the status of a specified package in the current R environment. It verifies whether the package is installed and, if so, compares the installed version with the latest version available online from CRAN. +#' #' @param package A character string specifying the name of the package to be checked. - -#' @return A numeric vector with the following elements: -#' \itemize{ -#' \item \code{[1]} Status code: -#' \itemize{ -#' \item \code{0} - Package not found (incorrect spelling). -#' \item \code{1} - Package found and installed. -#' \item \code{2} - Package found, but not installed. -#' } -#' \item \code{[2]} Version comparison result: -#' \itemize{ -#' \item \code{-1} - Installed version is older than the latest version. -#' \item \code{0} - Installed version is the same as the latest version. -#' \item \code{1} - Installed version is newer than the latest version. -#' } -#' \item \code{[3]} Installed version (if available), as a character string. -#' \item \code{[4]} Latest version available online (if available), as a character string. +#' +#' @return A named list with the following elements: +#' \describe{ +#' \item{status_code}{An integer indicating the package status:} +#' \itemize{ +#' \item \code{0} - Package name not found in CRAN (incorrect spelling or not a CRAN package). +#' \item \code{1} - Package is installed and up-to-date information is available. +#' \item \code{2} - Package is a CRAN package but not installed. +#' \item \code{3} - Package is installed but not found in CRAN (non-CRAN package). +#' \item \code{4} - Package is neither installed nor found in CRAN. +#' \item \code{5} - No internet connection available to check CRAN versions. +#' } +#' \item{version_comparison}{An integer comparing the installed and CRAN versions:} +#' \itemize{ +#' \item \code{-1} - Installed version is older than the CRAN version. +#' \item \code{0} - Installed version matches the CRAN version. +#' \item \code{1} - Installed version is newer than the CRAN version. +#' \item \code{NA} - Version comparison is not applicable (e.g., for non-CRAN packages). +#' } +#' \item{installed_version}{The installed version of the package (if available), as a character string.} +#' \item{cran_version}{The latest version available on CRAN (if available), as a character string.} #' } - +#' #' @export - -#' @examples #' +#' @examples #' # Check package "dplyr" -#' #package_check("dplyr") +#' package_check("dplyr") #' #' # Check package "ggplot2" -#' #package_check("ggplot2") - +#' package_check("ggplot2") package_check <- function(package) { out <- c() - if (!exists("av_packs")) { - create_av_packs() - } - if (package %in% rownames(utils::installed.packages())) { - out[[1]] <- 1 - v_machine <- as.character(utils::packageVersion(package)) - v_web <- as.character(av_packs[av_packs$Package == package, "Version"]) - out[[2]] <- utils::compareVersion(v_machine, v_web) - out[[3]] <- v_machine - out[[4]] <- v_web - return(out) - } else { - # Check if the package name is typed correctly - if (package %in% av_packs$Package) { - out[[1]] <- 2 - return(out) - } else { - # Incorrect spelling, check your spelling - out[[1]] <- 0 - return(out) + if (!pingr::is_online()) out[[1]] <- "5" + else{ + if(!exists("av_packs")) { + create_av_packs() + } + #CHECK the Package is a CRAN package + if (package %in% av_packs$Package){ + #PACKAGE IS INSTALLED + if (package %in% rownames(installed.packages())){ + out[[1]] <- "1" + v_machine <- as.character(packageVersion(package)) + v_web <- as.character(av_packs[av_packs$Package == package, "Version"]) + out[[2]] <- compareVersion(v_machine, v_web) + out[[3]] <- v_machine + out[[4]] <- v_web + } + else out[[1]] <- "2" + } + else{ + #PACKAGE IS INSTALLED BUT NOT IN THE CRAN REPO + if (package %in% rownames(installed.packages())) out[[1]] <- "3" + #PACKAGE IS NOT INSTALLED AND NOT IN THE CRAN REPO + else out[[1]] <- "4" } + } + return(out) } \ No newline at end of file diff --git a/man/cbind_unique.Rd b/man/cbind_unique.Rd index 0de83ae..a9f6f77 100644 --- a/man/cbind_unique.Rd +++ b/man/cbind_unique.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{cbind_unique} \alias{cbind_unique} \title{Bind Data Frames and Remove Duplicates} diff --git a/man/check_github_repo.Rd b/man/check_github_repo.Rd new file mode 100644 index 0000000..229e7fd --- /dev/null +++ b/man/check_github_repo.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/group_functions.R +\name{check_github_repo} +\alias{check_github_repo} +\title{Check GitHub Repository} +\usage{ +check_github_repo(owner = NULL, repo = NULL, url = NULL) +} +\arguments{ +\item{owner}{A character string specifying the GitHub repository owner. Defaults to \code{NULL}.} + +\item{repo}{A character string specifying the repository name. Defaults to \code{NULL}.} + +\item{url}{A character string specifying the full GitHub URL of the repository. Defaults to \code{NULL}.} +} +\value{ +An integer status code: +\describe{ +\item{0}{Package is installed and up-to-date.} +\item{1}{Package is installed but not the latest version.} +\item{2}{Unable to retrieve the latest commit from GitHub.} +\item{3}{Package is installed but not from GitHub.} +\item{4}{Repository exists and is an R package.} +\item{5}{Repository exists but is not an R package.} +\item{6}{Repository does not exist or an error occurred.} +} +} +\description{ +Verifies the existence and status of a GitHub repository, including whether it is an R package, +and checks if a locally installed package is up-to-date with the latest commit on GitHub. +} +\examples{ +# Check a repository using owner and repo +check_github_repo(owner = "hadley", repo = "ggplot2") + +# Check a repository using a URL +check_github_repo(url = "https://github.com/hadley/ggplot2") + +} diff --git a/man/check_graph.Rd b/man/check_graph.Rd index f4a6172..d0658c6 100644 --- a/man/check_graph.Rd +++ b/man/check_graph.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{check_graph} \alias{check_graph} \title{Check Graph} diff --git a/man/convert_to_list.Rd b/man/convert_to_list.Rd index 9d5f8ef..262e1e1 100644 --- a/man/convert_to_list.Rd +++ b/man/convert_to_list.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{convert_to_list} \alias{convert_to_list} \title{Convert Character to List of Numeric Vectors} diff --git a/man/frac10.Rd b/man/frac10.Rd new file mode 100644 index 0000000..8b41341 --- /dev/null +++ b/man/frac10.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/group_functions.R +\name{frac10} +\alias{frac10} +\title{Convert Decimal to Fraction} +\usage{ +frac10(x) +} +\arguments{ +\item{x}{A numeric value representing the decimal to convert.} + +\item{den}{An integer specifying the denominator for the fraction. (Only for \code{frac_den}.)} +} +\value{ +A character string representing the fraction. +} +\description{ +Converts a decimal value into a fraction with a specified denominator or common denominators (10, 20, or 100). +} +\examples{ +# Convert decimals to fractions +frac10(0.75) # "8/10" +frac20(0.25) # "5/20" +frac100(0.123) # "12/100" +frac_den(0.333, 3) # "1/3" + +} diff --git a/man/getExample.Rd b/man/getExample.Rd index c8bdc01..ba4a993 100644 --- a/man/getExample.Rd +++ b/man/getExample.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{getExample} \alias{getExample} \title{Get Example} diff --git a/man/getRowHeadersWithText.Rd b/man/getRowHeadersWithText.Rd index e7c223f..f016acd 100644 --- a/man/getRowHeadersWithText.Rd +++ b/man/getRowHeadersWithText.Rd @@ -1,10 +1,17 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{getRowHeadersWithText} \alias{getRowHeadersWithText} \title{Get Row Headers with Text} \usage{ -getRowHeadersWithText(data, column, searchText, ignore_case, use_regex) +getRowHeadersWithText( + data, + column, + searchText, + ignore_case, + use_regex, + match_entire_cell +) } \arguments{ \item{data}{The input data frame.} diff --git a/man/get_data_book_output_object_names.Rd b/man/get_data_book_output_object_names.Rd index d91180c..c69f68f 100644 --- a/man/get_data_book_output_object_names.Rd +++ b/man/get_data_book_output_object_names.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{get_data_book_output_object_names} \alias{get_data_book_output_object_names} \title{Get Data Book Output Object Names} diff --git a/man/get_data_book_scalar_names.Rd b/man/get_data_book_scalar_names.Rd new file mode 100644 index 0000000..fe3afd0 --- /dev/null +++ b/man/get_data_book_scalar_names.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/group_functions.R +\name{get_data_book_scalar_names} +\alias{get_data_book_scalar_names} +\title{Get Scalar Names from Data Book} +\usage{ +get_data_book_scalar_names( + scalar_list, + excluded_items = c(), + as_list = FALSE, + list_label = NULL +) +} +\arguments{ +\item{scalar_list}{A named list from which to extract scalar names.} + +\item{excluded_items}{A character vector of items to exclude from the output. Defaults to an empty vector.} + +\item{as_list}{A logical value indicating whether to return the result as a list. Defaults to \code{FALSE}.} + +\item{list_label}{A character string specifying the label for the list, if \code{as_list = TRUE}.} +} +\value{ +A character vector of scalar names, or a named list if \code{as_list = TRUE}. +} +\description{ +Extracts scalar names from a given list, with the option to exclude specific items, +return the names as a list, and provide a label for the list. +} +\examples{ +# Extract names excluding specific items +get_data_book_scalar_names(list(a = 1, b = 2, c = 3), excluded_items = c("b")) + +# Return the names as a list with a label +get_data_book_scalar_names(list(a = 1, b = 2), as_list = TRUE, list_label = "Scalars") + +} diff --git a/man/get_vignette.Rd b/man/get_vignette.Rd index 77d6257..0990845 100644 --- a/man/get_vignette.Rd +++ b/man/get_vignette.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{get_vignette} \alias{get_vignette} \title{Get Vignette} diff --git a/man/is.containPartialValueLabel.Rd b/man/is.containPartialValueLabel.Rd new file mode 100644 index 0000000..a895f0d --- /dev/null +++ b/man/is.containPartialValueLabel.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/iscontainPartialValueLabel.R +\name{is.containPartialValueLabel} +\alias{is.containPartialValueLabel} +\title{Check for Partial Value Labels} +\usage{ +is.containPartialValueLabel(x) +} +\arguments{ +\item{x}{A variable to check for partial value labels.} +} +\value{ +A logical value. Returns \code{TRUE} if the variable contains partial value labels, otherwise \code{FALSE}. +} +\description{ +Checks if the variable contains partial value labels (some values labeled, others not). +} +\examples{ +# Example with partially labeled variable +#is.containPartialValueLabel(x) + +} diff --git a/man/monitor_memory.Rd b/man/monitor_memory.Rd new file mode 100644 index 0000000..ba83ff5 --- /dev/null +++ b/man/monitor_memory.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/group_functions.R +\name{monitor_memory} +\alias{monitor_memory} +\title{Monitor Memory Usage} +\usage{ +monitor_memory() +} +\value{ +A numeric value representing the memory usage in MB. +} +\description{ +Monitors and returns the current memory usage in megabytes (MB). +} +\examples{ +# Check memory usage +monitor_memory() + +} diff --git a/man/package_check.Rd b/man/package_check.Rd index c3b85ad..6c1bb31 100644 --- a/man/package_check.Rd +++ b/man/package_check.Rd @@ -10,32 +10,35 @@ package_check(package) \item{package}{A character string specifying the name of the package to be checked.} } \value{ -A numeric vector with the following elements: +A named list with the following elements: +\describe{ +\item{status_code}{An integer indicating the package status:} \itemize{ -\item \code{[1]} Status code: +\item \code{0} - Package name not found in CRAN (incorrect spelling or not a CRAN package). +\item \code{1} - Package is installed and up-to-date information is available. +\item \code{2} - Package is a CRAN package but not installed. +\item \code{3} - Package is installed but not found in CRAN (non-CRAN package). +\item \code{4} - Package is neither installed nor found in CRAN. +\item \code{5} - No internet connection available to check CRAN versions. +} +\item{version_comparison}{An integer comparing the installed and CRAN versions:} \itemize{ -\item \code{0} - Package not found (incorrect spelling). -\item \code{1} - Package found and installed. -\item \code{2} - Package found, but not installed. +\item \code{-1} - Installed version is older than the CRAN version. +\item \code{0} - Installed version matches the CRAN version. +\item \code{1} - Installed version is newer than the CRAN version. +\item \code{NA} - Version comparison is not applicable (e.g., for non-CRAN packages). } -\item \code{[2]} Version comparison result: -\itemize{ -\item \code{-1} - Installed version is older than the latest version. -\item \code{0} - Installed version is the same as the latest version. -\item \code{1} - Installed version is newer than the latest version. -} -\item \code{[3]} Installed version (if available), as a character string. -\item \code{[4]} Latest version available online (if available), as a character string. +\item{installed_version}{The installed version of the package (if available), as a character string.} +\item{cran_version}{The latest version available on CRAN (if available), as a character string.} } } \description{ -This function checks the status of a specified package in the current R environment. It verifies whether the package is installed, and if so, it compares the installed version with the latest version available online. +This function checks the status of a specified package in the current R environment. It verifies whether the package is installed and, if so, compares the installed version with the latest version available online from CRAN. } \examples{ - # Check package "dplyr" -#package_check("dplyr") +package_check("dplyr") # Check package "ggplot2" -#package_check("ggplot2") +package_check("ggplot2") } diff --git a/man/process_html_object.Rd b/man/process_html_object.Rd index df6f0ed..ed566b9 100644 --- a/man/process_html_object.Rd +++ b/man/process_html_object.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{process_html_object} \alias{process_html_object} \title{Process Individual HTML Object} diff --git a/man/read_corpora.Rd b/man/read_corpora.Rd index cbd47c6..02681f9 100644 --- a/man/read_corpora.Rd +++ b/man/read_corpora.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{read_corpora} \alias{read_corpora} \title{Read and Process Corpora Data} diff --git a/man/time_operation.Rd b/man/time_operation.Rd new file mode 100644 index 0000000..5ac9c82 --- /dev/null +++ b/man/time_operation.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/group_functions.R +\name{time_operation} +\alias{time_operation} +\title{Time an Operation} +\usage{ +time_operation(expr) +} +\arguments{ +\item{expr}{An R expression to evaluate and time.} +} +\value{ +Prints the time taken for the operation. +} +\description{ +Measures and prints the time taken to execute an expression. +} +\examples{ +# Time a simple operation +time_operation({ Sys.sleep(1); mean(1:100) }) + +} diff --git a/man/view_graph_object.Rd b/man/view_graph_object.Rd index 9d1ef5d..f4de2c5 100644 --- a/man/view_graph_object.Rd +++ b/man/view_graph_object.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{view_graph_object} \alias{view_graph_object} \title{View Graph Object} diff --git a/man/view_html_object.Rd b/man/view_html_object.Rd index eb77301..1fd3e9b 100644 --- a/man/view_html_object.Rd +++ b/man/view_html_object.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{view_html_object} \alias{view_html_object} \title{View HTML Object} diff --git a/man/view_object.Rd b/man/view_object.Rd index 24a0792..65ab1b9 100644 --- a/man/view_object.Rd +++ b/man/view_object.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{view_object} \alias{view_object} \title{View Object} diff --git a/man/view_object_data.Rd b/man/view_object_data.Rd index 7958914..65a9d3b 100644 --- a/man/view_object_data.Rd +++ b/man/view_object_data.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{view_object_data} \alias{view_object_data} \title{View Object Data} diff --git a/man/view_text_object.Rd b/man/view_text_object.Rd index d69d46c..a627d3d 100644 --- a/man/view_text_object.Rd +++ b/man/view_text_object.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_corpora_to_ggwalter_lieth.R +% Please edit documentation in R/group_functions.R \name{view_text_object} \alias{view_text_object} \title{View Text Object}