conflicted

An alternative conflict resolution strategy for R

https://github.com/r-lib/conflicted

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    1 of 9 committers (11.1%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.2%) to scientific vocabulary

Keywords

conflicts r

Keywords from Contributors

tidy-data devtools setup visualisation documentation-tool package-creation parquet arrow graphics s3-vectors
Last synced: 10 months ago · JSON representation

Repository

An alternative conflict resolution strategy for R

Basic Info
Statistics
  • Stars: 253
  • Watchers: 3
  • Forks: 14
  • Open Issues: 10
  • Releases: 8
Topics
conflicts r
Created about 8 years ago · Last pushed over 2 years ago
Metadata Files
Readme License Code of conduct

README.Rmd

---
output: github_document
---



```{r, echo = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)
set.seed(1014)
```

# conflicted


[![R-CMD-check](https://github.com/r-lib/conflicted/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/conflicted/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/r-lib/conflicted/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/conflicted?branch=main)


The goal of conflicted is to provide an alternative conflict resolution strategy. R's default conflict resolution system gives precedence to the most recently loaded package. This can make it hard to detect conflicts, particularly when introduced by an update to an existing package. conflicted takes a different approach, making every conflict an error and forcing you to choose which function to use.

Thanks to [\@krlmlr](https://github.com/krlmlr) for this neat idea! This code was previously part of the experimental [strict](https://github.com/hadley/strict) package, but I decided improved conflict resolution is useful by itself and worth its own package.

## Installation

```{r, eval = FALSE}
# install.packages("pak")
pak::pak("r-lib/conflicted")
```

## Usage

To use conflicted, all you need to do is load it:

```{r, error = TRUE}
library(conflicted)
library(dplyr)

filter(mtcars, cyl == 8)
```

As suggested, you can either namespace individual calls:

```{r}
dplyr::filter(mtcars, am & cyl == 8)
```

Or declare a session-wide preference:

```{r}
conflicts_prefer(dplyr::filter())
filter(mtcars, am & cyl == 8)
```

I recommend declaring preferences directly underneath the corresponding library call:

```{r, eval = FALSE}
library(dplyr)
conflicts_prefer(dplyr::filter)
```

You can ask conflicted to report any conflicts in the current session:

```{r}
conflict_scout()
```

Functions surrounded by `[]` have been chosen using one of the built-in rules. Here `filter()` has been selected because of the preference declared above; the set operations have been selected because they follow the superset principle and extend the API of the base equivalents.

### How it works

Loading conflicted creates a new "conflicted" environment that is attached just after the global environment. This environment contains an active binding for any object that is exported by multiple packages; the active binding will throw an error message describing how to disambiguate the name. The conflicted environment also contains bindings for `library()` and `require()` that suppress conflict reporting and update the conflicted environment with any new conflicts.

## Alternative approaches

It is worth comparing conflicted to [box](https://github.com/klmr/box) and [import](https://github.com/rticulate/import). Both packages provide strict alternatives to `library()`, giving much finer control over what functions are added to the search path.

```{r, eval = FALSE}
# box expects you to either namespace all package functions or to load them explicitly
box::use(dplyr)
dplyr$filter(mtcars, cyl == 8)
# or:
box::use(dplyr[select, arrange, dplyr_filter = filter])
dplyr_filter(mtcars, cyl == 8)

# import expects you to explicitly load functions
import::from(dplyr, select, arrange, dplyr_filter = filter)
dplyr_filter(mtcars, cyl == 8)
```

These require more upfront work than conflicted, in return for greater precision and control.

Since conflicted was created base R also improved its tools for managing search path conflicts. See [the blog post](https://developer.r-project.org/Blog/public/2019/03/19/managing-search-path-conflicts/) by Luke Tierney for details. The main difference is that base R requires up front conflict resolution of all functions when loading a package; conflicted only reports problems as you use conflicted functions.

## Code of Conduct

Please note that the conflicted project is released with a [Contributor Code of Conduct](https://conflicted.r-lib.org/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.

Owner

  • Name: R infrastructure
  • Login: r-lib
  • Kind: organization

GitHub Events

Total
  • Issues event: 9
  • Watch event: 7
  • Issue comment event: 17
  • Fork event: 1
Last Year
  • Issues event: 9
  • Watch event: 7
  • Issue comment event: 17
  • Fork event: 1

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 213
  • Total Committers: 9
  • Avg Commits per committer: 23.667
  • Development Distribution Score (DDS): 0.099
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
hadley h****m@g****m 192
Kirill Müller k****l@c****m 10
Katrin Leinweber k****r@u****e 4
Mara Averick m****k@g****m 2
Romain François r****n@p****t 1
Nicholas Erskine n****1@g****m 1
Michael Chirico m****4@g****m 1
Lionel Henry l****y@g****m 1
Konrad Rudolph k****h@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 89
  • Total pull requests: 25
  • Average time to close issues: 7 months
  • Average time to close pull requests: 20 days
  • Total issue authors: 56
  • Total pull request authors: 9
  • Average comments per issue: 2.58
  • Average comments per pull request: 0.96
  • Merged pull requests: 19
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 3
  • Pull requests: 0
  • Average time to close issues: 3 days
  • Average time to close pull requests: N/A
  • Issue authors: 3
  • Pull request authors: 0
  • Average comments per issue: 0.33
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • hadley (26)
  • krlmlr (4)
  • sanjmeh (3)
  • emstruong (3)
  • uhkeller (2)
  • devillemereuil (1)
  • moodymudskipper (1)
  • SamGG (1)
  • mike-lawrence (1)
  • Breza (1)
  • romainfrancois (1)
  • motheeyue (1)
  • mvaudel (1)
  • markusdumke (1)
  • ijlyttle (1)
Pull Request Authors
  • hadley (11)
  • krlmlr (5)
  • batpigandme (2)
  • klmr (2)
  • romainfrancois (1)
  • nerskin (1)
  • Farbfetzen (1)
  • MichaelChirico (1)
  • lionel- (1)
Top Labels
Issue Labels
feature (6) bug (1) upkeep (1) documentation (1)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • cran 386,886 last-month
  • Total docker downloads: 45,209,964
  • Total dependent packages: 19
    (may contain duplicates)
  • Total dependent repositories: 86
    (may contain duplicates)
  • Total versions: 21
  • Total maintainers: 1
cran.r-project.org: conflicted

An Alternative Conflict Resolution Strategy

  • Versions: 8
  • Dependent Packages: 18
  • Dependent Repositories: 83
  • Downloads: 386,886 Last month
  • Docker Downloads: 45,209,964
Rankings
Downloads: 0.5%
Stargazers count: 1.8%
Dependent repos count: 2.5%
Dependent packages count: 3.8%
Average: 5.2%
Forks count: 5.6%
Docker downloads count: 17.3%
Maintainers (1)
Last synced: 11 months ago
proxy.golang.org: github.com/r-lib/conflicted
  • Versions: 8
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 11 months ago
conda-forge.org: r-conflicted
  • Versions: 5
  • Dependent Packages: 1
  • Dependent Repositories: 3
Rankings
Dependent repos count: 18.1%
Stargazers count: 24.8%
Average: 28.9%
Dependent packages count: 29.0%
Forks count: 43.9%
Last synced: 11 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.2 depends
  • memoise * imports
  • rlang >= 0.3.4 imports
  • Matrix * suggests
  • callr * suggests
  • crayon * suggests
  • dplyr * suggests
  • methods * suggests
  • pkgload * suggests
  • testthat >= 3.0.0 suggests
tests/testthat/data/DESCRIPTION cran
  • R >= 2.10 depends
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pr-commands.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/pr-fetch v2 composite
  • r-lib/actions/pr-push v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite