{"id":32203264,"url":"https://github.com/mnist91/origin","last_synced_at":"2025-10-22T04:36:24.335Z","repository":{"id":54253641,"uuid":"342809825","full_name":"mnist91/origin","owner":"mnist91","description":"An R Package that adds package:: to functions.","archived":false,"fork":false,"pushed_at":"2024-11-24T20:16:38.000Z","size":2513,"stargazers_count":11,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-10-11T05:12:48.838Z","etag":null,"topics":["addin","r","rpackage"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mnist91.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-27T08:42:27.000Z","updated_at":"2025-03-22T04:43:38.000Z","dependencies_parsed_at":"2024-11-24T23:47:14.441Z","dependency_job_id":null,"html_url":"https://github.com/mnist91/origin","commit_stats":{"total_commits":363,"total_committers":6,"mean_commits":60.5,"dds":0.2644628099173554,"last_synced_commit":"9b149e26f0a234541233a34ae972648bba4f1a18"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/mnist91/origin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnist91%2Forigin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnist91%2Forigin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnist91%2Forigin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnist91%2Forigin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mnist91","download_url":"https://codeload.github.com/mnist91/origin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnist91%2Forigin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280382203,"owners_count":26321419,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["addin","r","rpackage"],"created_at":"2025-10-22T04:36:21.778Z","updated_at":"2025-10-22T04:36:24.329Z","avatar_url":"https://github.com/mnist91.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# origin - 1.2.0 \u003cimg src=\"misc/origin.png\" width=170 align=\"right\" /\u003e\n\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/origin)](https://cran.r-project.org/package=origin)\n[![metacran downloads](https://cranlogs.r-pkg.org/badges/grand-total/origin)](https://cran.r-project.org/package=origin)\n[![codecov](https://codecov.io/gh/mnist91/origin/branch/main/graph/badge.svg)](https://app.codecov.io/gh/mnist91/origin?branch=main)\n[![R-CMD-check](https://github.com/mnist91/origin/actions/workflows/r-cmd-check-fix.yml/badge.svg)](https://github.com/mnist91/origin/actions/workflows/r-cmd-check-fix.yml)\n\n| branch        | main | dev  |\n| ------------- | ------ | ---- |\n| R CMD check   | [![main](https://github.com/mnist91/origin/actions/workflows/r-cmd-check-fix.yml/badge.svg?branch=main)](https://github.com/mnist91/origin/actions/workflows/r-cmd-check-fix.yml) | [![dev](https://github.com/mnist91/origin/actions/workflows/r-cmd-check-fix.yml/badge.svg?branch=dev)](https://github.com/mnist91/origin/actions/workflows/r-cmd-check-fix.yml) |\n| test coverage | [![main-test-coverage](https://img.shields.io/codecov/c/github/mnist91/origin/main.svg)](https://app.codecov.io/gh/mnist91/origin/branch/main) | [![dev-test-coverage](https://img.shields.io/codecov/c/github/mnist91/origin/dev.svg)](https://app.codecov.io/gh/mnist91/origin/branch/dev) |\n| lints         | [![main-lints](https://github.com/mnist91/origin/actions/workflows/lints.yml/badge.svg?branch=main)](https://github.com/mnist91/origin/actions/workflows/lints.yml) | [![dev-lints](https://github.com/mnist91/origin/actions/workflows/lints.yml/badge.svg?branch=dev)](https://github.com/mnist91/origin/actions/workflows/lints.yml) |\n\n\nAn R package that adds `pkg::` to functions to be more explicit\n\n\nTo install the latest version use `remotes::install_github(\"mnist91/origin\")`\n\n\n## Overview\n\n`origin` adds the correct package specification to all functions in your script\nwhile giving full control about the outcome. This makes it much easier to both\nconvert legacy code into the `pkg::fun()` convention as well as it allows you to \nwrite short code first and adapt it later. \n\n\n\u003cimg src=\"https://raw.githubusercontent.com/mnist91/origin/dev/misc/demo_originize_file.gif\" width=\"650px\" /\u003e\n\nAdditionally, it provides an overview of all **actually** used packages in a project. \nThat means, it does not only check which packages are called via `library()`,\n`require()`, etc. but determines which functions from which packages are eventually used.\nUseful for quickly checking a project for which packages \nare actually still needed when dealing with a huge barrage of `library` calls.\n\n\u003cimg src=\"https://raw.githubusercontent.com/mnist91/origin/dev/misc/check_pkg_usage.png\" width=\"650px\" /\u003e\n\n\n### Usage\n#### Originize Code\nTo originize code either use the delivered RStudio addins or call the `origin`\nfunctions directly, i.e. `origin::originize_file` or `origin::originize_dir`.\n\n```\norigin::originize_file(\"testfile.R\", pkgs = c(\"dplyr\", \"data.table\"))\n```\n\n#### Check Package Usage\nAgain, either use the delivered RStudio addin or call the function explicitly\n```\norigin::check_pkg_usage(path = \".\",\n                        pkgs = c(\"dplyr\", \"data.table\"),\n                        use_markes = FALSE)\n```\n\n### Settings\nMost argument defaults of `origin` functions can be set via `options()`. \nThis is especially useful when using the RStudio Addins.\n\n  - `origin.pkgs`: which packages to check for functions used in the code (see **Considered Packages**).\n  - `origin.ask_before_applying_changes`: whether changes should be applied\n    immediately or the user must approve them first. Note that this mutes all\n    checks, i.e. large number of files, local functions mask exported functions,\n    and the presence and order of function conflicts.\n  - `origin.overwrite`: actually insert `pkg::` into the code. Otherwise,\n  logging shows only what *would* happen. Note that `ask_before_applying_changes`\n  still allows to keep control over your code before `origin` changes anything.\n  - `origin.check_conflicts`: should `origin` check for potential \n  namespace conflicts, i.e. a used function is defined in more than one considered\n  package. User input is required to solve the issue. \n  Strongly encouraged to be set to `TRUE`.\n  - `origin.add_base_packages`: should base packages also be added, e.g. `base::sum()`.\n  - `origin.check_base_conflicts`: Should origin also check for conflicts\n  with base R functions.\n  - `origin.check_local_conflicts`: Should origin also check for conflicts\n  with locally defined functions anywhere in your project? Note that it does not\n  check the environment but solely parses files and scans them for function definitions\n  - `origin.path_to_local_functions`: the path to the root directory of all local functions.\n  defaults to the project root of the currently opened project in RStudio.\n  - `origin.excluded_functions`: a (named) list of functions to exclude from checking. See details.\n  - `origin.verbose`: some sort of logging is performed, either in the \n  console or via the markers tab in RStudio.\n  - `origin.use_markers_for_logging`: whether to use the Markers tab in RStudio.\n  - `origin.color_added_package`: hex code highlighting insertions.\n  - `origin.color_missed_function`: hex code highlighting potential missings.\n  - `origin.color_infix_function`: hex code highlighting infix functions (see discussion).\n  - `origin.filetypes`: Which filetypes to consider. Now origin supports .R, .Rmd, and .Qmd (Quarto) files.\n\n\n### Considered Packages\nBy default, `orgigin` considers all attached packages as given by `.packages()` \nexcept the standard R packages (`base`, `methods`, `stats`, `utils`, `graphics`, \n`datasets`). For the current list of loaded packages also check `search()`.\nNote that, in case of namespace conflicts, the order in the search list \ndetermines which namespace masks which. `origin` uses the same rule as R, i.e.\nthe latest loaded package masks the other packages. Therefore, in case\nthere is a potential namespace conflict in your code, the changes made by \n`origin` should yield the same result as before but being more explicit\nabout it. Since this can break code functionality, `origin` issues a warning and \nuser input is required. \n\nTo overwrite the default just use a character vector of package names.\n\n### Exclude Functions\n\nEspecially useful to solve **namespace conflicts** or ignore infix functions\nlike the pipe operator `%\u003e%`. Listed functions are not considered by `origin` \nneither in adding `pkg::` nor logging. It is a list of function names. When unnamed, the \nfunction is generally excluded. To be more specific, a named list excludes functions\nfrom these packages only. \n\nExamples:\n\n```\n# unnamed list\nopitions(origin.excluded_functions = list(\"last\", \"%\u003e%\", \"%\u003c\u003e%\"))\n\n# named list\nopitions(origin.excluded_functions = list(data.table = c(\"last\", %between%),\n                                          magrittr = c(\"%\u003e%\", \"%\u003c\u003e%\")))\n\n# both named and unnamed\nopitions(origin.excluded_functions = list(data.table = c(\"last\", %between%),\n                                          \"%\u003e%\", \"%\u003c\u003e%\"))\n```\n### Logging Interpretation\nThe logging highlights three cases:\n- insertion: `pkg::` is inserted prior to a function\n- missing: an object that has the same name as a function \n           but not undoubtedly used as a function. In R it is usually no problem\n           to have variables that name like functions (data or df are popular examples).\n           While it is always clear when a function is directly used as one, functions\n           can also be arguments of other functions, most famously in functional programming \n           like the *apply family or purrr. `origin` highlights such cases in \n           the logging output.\n- infix: functions like `%\u003e%` are exported by packages but cannot be called\n           with the `pkg::fun()` convention. Such functions are highlighted by default\n           to point the user that these stem from a package. When using \n           dplyr-style code, consider to exclude the pipe-operator via \n           `exclude_functions`.\n                                \n\n\n\n\n\n### Discussion\nWhether or not to add `pkg::` to each (imported) function is a [controversial](https://stackoverflow.com/q/4372145/8107362)\n[issue](https://stackoverflow.com/q/23232791/8107362) in the R community. While the tidyverse style guide does not mention explicit namespacing, [R Packages](https://r-pkgs.org) and the [Google R style guide](https://google.github.io/styleguide/Rguide.html#qualifying-namespaces) are in favor of it.\n\nPros\n\n+ very explicit\n+ completely avoid namespace conflicts\n+ no need to attach the complete namespace of a package\n+ keep track of which function belongs to which package\n\nCons \n\n- (minimal) performance issue\n- more writing required\n- longer code\n- infix functions like `%\u003e%` cannot be called via `magrittr::%\u003e%`\nand workarounds are still required here. Either use \n  ```\n  library(magrittr, include.only = \"%\u003e%\")\n  `%\u003e%` \u003c- magrittr::`%\u003e%`\n  ```\n- calling `library()` on top of a script clearly indicates which packages are\n  needed. A not yet installed package throws an error right away, not until\n  a function cannot be found later in the script. However, one can use \n  the `include_only` argument and set it to `NULL`. No functions are attached\n  into the search list then.\n  ```\n  library(magrittr, include_only = NULL)\n  ``` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnist91%2Forigin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmnist91%2Forigin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnist91%2Forigin/lists"}