Code Monkey home page Code Monkey logo

pacs's Introduction

pacs

R build status CRAN codecov

For more information please visit the pacs website.

Functions Reference

A set of tools that make life easier for developers and maintainers of R packages.

  • Validating the library, packages and renv lock files.
  • Exploring complexity of a certain package like evaluating its size in bytes with dependencies.
  • The shiny app complexity could be explored too.
  • Assessing the life duration of a specific package version.
  • Checking a CRAN package check page status for any errors and warnings.
  • Retrieving a DESCRIPTION or NAMESPACE file for any package version.
  • Comparing DESCRIPTION or NAMESPACE files between different package versions.
  • Getting a list of all releases for a specific package.
  • The Bioconductor is partly supported.

An Internet connection is required to take full advantage of most of the features.

Almost all calls which requiring an Internet connection are cached (for 30 minutes) by the memoise package, so the second invocation of the same command (and arguments) is immediate. Restart the R session if you want to clear cached data.

Installation

Development version:

# install.packages("remotes")
remotes::install_github("polkas/pacs")

CRAN:

install.packages("pacs")

Examples

For more examples with descriptions please visit the walk-through vignette.

Validate the library:

pacs::lib_validate(
  checkred = list(
    scope = c("ERROR", "FAIL"),
    # by default all flavors
    flavors = NULL
  )
)

All package check statuses for all CRAN servers:

pacs::checked_packages()

All CRAN releases of a package:

pacs::pac_timemachine("dplyr")

Compare package DESCRIPTION file dependencies between versions:

pacs::pac_compare_versions("shiny", "1.0.0", "1.5.0")

Looking for heavy dependencies:

pacs::pac_deps_heavy("caret")

pacs's People

Contributors

polkas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pacs's Issues

Tinyverse vignette

Tinyverse

How to weight a package

Difference between dependencies types

why testthat is ok compared to tinytest as is in Suggests

RequireNamespce solution

valid_pac function

The same as valid_lib we want to offer to valid_pac. This will be used to see have our installation looks compared to description file.

lock validate improvements

add check if all packages are in the lock
setdiff(setdiff(base::union(unlist(tools::package_dependencies(pacs::lock_validate(url)[,1])), pacs::lock_validate(url)[,1]), pacs::lock_validate(url)[,1]), pacs::pacs_base())

Some shiny related functions

For shiny app we do not have description files, unfortunately mostly. We have to grep for library require pacman::p_load.
We could made a shiny_true_size ...
shiny_deps

Valuable to check out packrat

What mean package version, how old they are ...

Nice to provide the option to check out when a package was released. We could get it from CRAN webpages. get_deps could have additional column with number of month difference between what i have and what is a minimum required.

Or SB want to know across all packages how old are each one of them.

Find exported functions usage

Example code:

# Improved function to get only exported functions from a package
get_exported_functions <- function(package_name) {
  exported_objects <- getNamespaceExports(package_name)
  exported_functions <- exported_objects[sapply(exported_objects, function(name) {
    is.function(get(name, envir = asNamespace(package_name)))
  })]
  return(exported_functions)
}

# Function to recursively list all files in a directory remains unchanged
list_files_recursively <- function(path) {
  all_files <- list.files(path, full.names = TRUE, recursive = TRUE)
  return(all_files)
}

# Improved function to search for a regex pattern in files
search_pattern_in_files <- function(files, patterns) {
  results <- list()
  # Compile a single regex pattern from all patterns for efficiency
  compiled_pattern <- paste0("\\b(", paste(patterns, collapse = "|"), ")\\b\\s*\\(")
  
  for (file_path in files) {
    # Process only R and Rmd files
    if (grepl("\\.R$", file_path) || grepl("\\.Rmd$", file_path)) {
      tryCatch({
        content <- readLines(file_path, warn = FALSE)
        for (i in seq_along(content)) {
          if (grepl(compiled_pattern, content[i], perl = TRUE)) {
            matched_function <- regmatches(content[i], regexpr(compiled_pattern, content[i]))
            results[[length(results) + 1]] <- list(file = file_path, line = i, text = content[i], pattern = matched_function)
          }
        }
      }, error = function(e) {
        message(sprintf("Error reading %s: %s", file_path, e$message))
      })
    }
  }
  return(results)
}

# Main execution function remains conceptually the same but with improved internal logic
search_for_exported_functions_usage <- function(package_name, directories) {
  exported_functions <- get_exported_functions(package_name)
  all_files <- unlist(lapply(directories, list_files_recursively))
  search_results <- search_pattern_in_files(all_files, exported_functions)
  
  if (length(search_results) > 0) {
    for (result in search_results) {
      cat(sprintf("File: %s, Line: %d, Pattern: %s, Text: %s\n", result$file, result$line, result$pattern, result$text))
    }
  } else {
    cat("No matches found.\n")
  }
}

# Define directories to search and execute the search
directories <- c("R", "vignettes", "tests/testthat")
search_for_exported_functions_usage("dplyr", directories)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.