https://github.com/samedwardes/safejoin
Perform "safe" table joins in R.
https://github.com/samedwardes/safejoin
data-base data-science r
Last synced: 17 days ago
JSON representation
Perform "safe" table joins in R.
- Host: GitHub
- URL: https://github.com/samedwardes/safejoin
- Owner: SamEdwardes
- License: other
- Created: 2021-04-17T16:22:25.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-12T21:02:44.000Z (over 1 year ago)
- Last Synced: 2025-04-13T22:23:14.096Z (10 months ago)
- Topics: data-base, data-science, r
- Language: R
- Homepage: https://safejoin-r.netlify.app/
- Size: 140 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# safejoin
[](https://github.com/SamEdwardes/safejoin/actions) [](https://cran.r-project.org/package=safejoin)
## 🚧 Deprecation notice 🚧
As of `safejoin` version 0.2.0 the package has been deprecated. As of version [`1.1.1`](https://dplyr.tidyverse.org/news/index.html#dplyr-111) dplyr has a `relationship` argument that provides the same functionality that `safejoin` was created for. See the dplyr docs [https://dplyr.tidyverse.org/reference/mutate-joins.html](https://dplyr.tidyverse.org/reference/mutate-joins.html) for complete details.
Please use `dplyr::left_join()` with the `relationship` argument instead.
## About
The goal of safejoin is to guarantee that when performing joins that extra rows are not added to your data. safejoin is a wrapper around the [`dplyr::left_join`](https://dplyr.tidyverse.org/reference/mutate-joins.html) function.
- [Docs](https://safejoin-r.netlify.app/)
- [GitHub](https://github.com/SamEdwardes/safejoin/)
- [CRAN](https://CRAN.R-project.org/package=safejoin)
## Installation
You can install the released version of safejoin from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("safejoin")
```
Install development version from GitHub:
``` r
devtools::install_github("SamEdwardes/safejoin", ref = "dev")
```
## Example
Depending on your need safejoin can raise an error, a warning, or a message. By default safejoin will raise an error.
**Error**:
```{r example, error=TRUE}
library(safejoin)
x <- data.frame(key = c("a", "b"), value_x = c(1, 2))
y <- data.frame(key = c("a", "a"), value_y = c(1, 1))
safe_left_join(x, y, by = "key")
```
**Warning**:
```{r example_warning}
safe_left_join(x, y, by = "key", action="warning")
```
**Message**:
```{r example_message}
safe_left_join(x, y, by = "key", action="message")
```
When a join is "safe" `safe_left_join` will have the exact same behavior as [`dplyr::left_join`](https://dplyr.tidyverse.org/reference/mutate-joins.html).
```{r}
x <- data.frame(key = c("a", "b"), value_x = c(1, 2))
y <- data.frame(key = c("a", "b"), value_y = c(1, 1))
safe_left_join(x, y, by = "key")
```
## Other useful packages
There are other packages that help solve similar problems. Most notably provides great features to treat data frames like a data base.
## Reference and Attribution
safejoin is created and maintained by Sam Edwardes.