Skip to content

Commit

Permalink
Merge pull request #44 from RossanaTat/update_all
Browse files Browse the repository at this point in the history
Updating some tests, adding vignettes and website
  • Loading branch information
randrescastaneda authored Feb 22, 2024
2 parents 98fd232 + 5ddf231 commit 5e4e92c
Show file tree
Hide file tree
Showing 97 changed files with 10,228 additions and 1,576 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
branches: [main, master, website]
pull_request:
branches: [main, master]
branches: [main, master, website]

name: R-CMD-check

Expand Down
62 changes: 31 additions & 31 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches:
- main
- master
branches: [master, DEV, update_all]
pull_request:
branches: [master, DEV]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: macOS-latest
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-pandoc@v1

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Restore R package cache
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
extra-packages: any::pkgdown, local::.
needs: website

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
install.packages("pkgdown", type = "binary")
- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Install package
run: R CMD INSTALL .

- name: Deploy package
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
4 changes: 2 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
branches: [main, master, website]
pull_request:
branches: [main, master]
branches: [main, master, website]

name: test-coverage

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
inst/doc
doc
Meta
docs
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: joyn
Type: Package
Title: Tool for Diagnosis of Tables Joins and Complementary Join Features
Version: 0.1.5
Version: 0.1.6
Authors@R: c(person(given = "R.Andres",
family = "Castaneda",
email = "[email protected]",
Expand All @@ -20,7 +20,7 @@ Description: Tool for diagnosing table joins. It combines the speed of `collapse
of the `merge` command in `Stata`.
License: MIT + file LICENSE
Encoding: UTF-8
URL: https://github.com/randrescastaneda/joyn
URL: https://github.com/randrescastaneda/joyn, https://rossanatat.github.io/joyn/
BugReports: https://github.com/randrescastaneda/joyn/issues
Suggests:
badger,
Expand All @@ -29,15 +29,16 @@ Suggests:
rmarkdown,
testthat (>= 3.0.0),
withr,
dplyr
dplyr,
tibble
Config/testthat/edition: 3
Imports:
rlang,
data.table,
glue,
cli,
utils,
collapse (>= 2.0.7),
collapse (>= 2.0.9),
lifecycle
Depends:
R (>= 2.10)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export(is_id)
export(joyn)
export(joyn_msg)
export(left_join)
export(merge)
export(possible_ids)
export(rename_to_valid)
export(right_join)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# joyn 0.1.6

# joyn 0.1.5

# joyn 0.1.4
Expand Down
55 changes: 28 additions & 27 deletions R/checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' x = 11:15)
#' y1 = data.table(id = c(1,2, 4),
#' y = c(11L, 15L, 16))
#' check_xy(x = x1, y=y1)
#' joyn:::check_xy(x = x1, y=y1)
#' }
check_xy <- function(x,y) {

Expand Down Expand Up @@ -70,20 +70,22 @@ check_xy <- function(x,y) {
#' @param dt data.frame to check
#' @param name var name to check if has duplicates in dt
#' @return logical either TRUE, if any duplicates are found, or FALSE otherwise
#' @keywords internal
#'
#' @examples
#' \dontrun{
#' # When no duplicates
#' x1 = data.table(id = c(1L, 1L, 2L, 3L, NA_integer_),
#' t = c(1L, 2L, 1L, 2L, NA_integer_),
#' x = 11:15)
#' check_duplicate_names(x1, "x")
#' joyn:::check_duplicate_names(x1, "x")
#'
#' # When duplicates
#' x1_duplicates = data.frame(id = c(1L, 1L, 2L, 3L, NA_integer_),
#' x = c(1L, 2L, 1L, 2L, NA_integer_),
#' x = 11:15,
#' check.names = FALSE)
#' check_duplicate_names(x1_duplicates, "x")
#' joyn:::check_duplicate_names(x1_duplicates, "x")
#' }
check_duplicate_names <- \(dt, name) {
nm_x = names(dt)
Expand All @@ -93,8 +95,8 @@ check_duplicate_names <- \(dt, name) {
store_msg("err",
err = paste(cli::symbol$cross, "Error:"),
pale = " Table {.field {name}} has the following
{cli::qty(length(dups))} column{?s} duplicated:",
timing = "{.var {dups}}",
{cli::qty(length(dups))} column{?s} duplicated:",
timing = "{.var {dups}}",
pale = "\nPlease rename or remove and try again.")
return(TRUE)
}
Expand All @@ -111,21 +113,21 @@ check_duplicate_names <- \(dt, name) {
#' @examples
#' \dontrun{
#' # When null - reporting variable not returned in merged dt
#' check_reportvar(reportvar = NULL)
#' joyn:::check_reportvar(reportvar = NULL)
#' # When FALSE - reporting variable not returned in merged dt
#' check_reportvar(reportvar = FALSE)
#' joyn:::check_reportvar(reportvar = FALSE)
#' # When character
#' check_reportvar(reportvar = ".joyn")
#' joyn:::check_reportvar(reportvar = ".joyn")
#' }

check_reportvar <-
function(reportvar, verbose = getOption("joyn.verbose")) {
if (is.character(reportvar)) {
reportvar <- rename_to_valid(reportvar, verbose)
store_msg("info",
ok = cli::symbol$info, " ", ok = cli::symbol$pointer,
ok = cli::symbol$info, " ", ok = cli::symbol$pointer,
" ",
pale = "Joyn's report available in variable",
pale = "Joyn's report available in variable",
bolded_pale = " {reportvar}")

return(reportvar)
Expand All @@ -134,8 +136,8 @@ check_reportvar <-

store_msg("info",
ok = paste(cli::symbol$info, " Note:"),
pale = " Reporting variable is",
bolded_pale = "\nnot",
pale = " Reporting variable is",
bolded_pale = "\nnot",
pale = "\nreturned")

return(NULL)
Expand Down Expand Up @@ -164,7 +166,7 @@ check_reportvar <-
#' y1 = data.frame(id = 1:2,
#' y = c(11L, 15L))
#' # With var "id" shared in x and y
#' check_by_vars(by = "id", x = x1, y = y1)
#' joyn:::check_by_vars(by = "id", x = x1, y = y1)
#'}
check_by_vars <- function(by, x, y) {

Expand Down Expand Up @@ -215,10 +217,10 @@ check_by_vars <- function(by, x, y) {
#' x = 11:15)
#' y1 = data.frame(id = 1:2,
#' y = c(11L, 15L))
#' check_match_type(x = x1, y=y1, by="id", match_type = "m:1")
#' joyn:::check_match_type(x = x1, y=y1, by="id", match_type = "m:1")
#'
#' # Inconsistent match type
#' check_match_type(x = x1, y=y1, by="id", match_type = "1:1")
#' joyn:::check_match_type(x = x1, y=y1, by="id", match_type = "1:1")
#' }
check_match_type <- function(x, y, by, match_type, verbose) {

Expand Down Expand Up @@ -335,7 +337,7 @@ check_match_type <- function(x, y, by, match_type, verbose) {
#' x1 = data.table(id = c(1L, 1L, 2L, 3L, NA_integer_),
#' t = c(1L, 2L, 1L, 2L, NA_integer_),
#' x = 11:15)
#' is_match_type_error(x1, name = "x1", by = "id")
#' joyn:::is_match_type_error(x1, name = "x1", by = "id")
#' }

is_match_type_error <- function(x, name, by, verbose, match_type_error) {
Expand All @@ -349,7 +351,7 @@ is_match_type_error <- function(x, name, by, verbose, match_type_error) {
store_msg("err",
err = paste(cli::symbol$cross, "Error:"),
pale = " table",
bolded_pale = " {name}",
bolded_pale = " {name}",
pale = " is not uniquely identified by",
bolded_pale = " {by2}")

Expand All @@ -375,11 +377,11 @@ is_match_type_error <- function(x, name, by, verbose, match_type_error) {
#' y1 = data.table(id = 1:2,
#' y = c(11L, 15L))
#' # With y_vars_to_keep TRUE
#' check_y_vars_to_keep(TRUE, y1, by = "id")
#' joyn:::check_y_vars_to_keep(TRUE, y1, by = "id")
#' # With y_vars_to_keep FALSE
#' check_y_vars_to_keep(FALSE, y1, by = "id")
#' joyn:::check_y_vars_to_keep(FALSE, y1, by = "id")
#' # Specifying which y vars to keep
#' check_y_vars_to_keep("y", y1, by = "id")
#' joyn:::check_y_vars_to_keep("y", y1, by = "id")
#' }

check_y_vars_to_keep <- function(y_vars_to_keep, y, by) {
Expand Down Expand Up @@ -456,11 +458,11 @@ check_y_vars_to_keep <- function(y_vars_to_keep, y, by) {
#' yd = c(1, 2, 5, 6, 3),
#' y = c(11L, 15L, 20L, 13L, 10L),
#' x = c(16:20))
#' y_vars_to_keep <- check_y_vars_to_keep(TRUE, y2, by = "id")
#' joyn:::y_vars_to_keep <- check_y_vars_to_keep(TRUE, y2, by = "id")
#' x2 = data.frame(id = c(1, 1, 2, 3, NA),
#' t = c(1L, 2L, 1L, 2L, NA_integer_),
#' x = c(16, 12, NA, NA, 15))
#' check_new_y_vars(x = x2, by="id", y_vars_to_keep)
#' joyn:::check_new_y_vars(x = x2, by="id", y_vars_to_keep)
#' }

check_new_y_vars <- \(x, by, y_vars_to_keep) {
Expand All @@ -478,8 +480,8 @@ check_new_y_vars <- \(x, by, y_vars_to_keep) {
"note",
ok = paste(cli::symbol$info, " ", cli::symbol$pointer, " "),
pale = "variable{?s} ",
bolded_pale = "{upvars}",
pale = " in table",
bolded_pale = "{upvars}",
pale = " in table",
bolded_pale = " {y}",
pale = " {?is/are} ignored because arguments",
bolded_pale = " update_NAs and update_values",
Expand Down Expand Up @@ -510,13 +512,13 @@ check_new_y_vars <- \(x, by, y_vars_to_keep) {
#' t = c(1L, 2L, 1L, 2L, NA_integer_),
#' x = 11:15)
#'
#' is_valid_m_key(x1, by = c("id", "t"))
#' joyn:::is_valid_m_key(x1, by = c("id", "t"))

#' # example with valid specified "many" relationship
#' x2 = data.frame(id = c(1L, 1L, 1L, 3L, NA_integer_),
#' t = c(1L, 2L, 1L, 2L, NA_integer_),
#' x = 11:15)
#' is_valid_m_key(x2, by = c("id", "t"))
#' joyn:::is_valid_m_key(x2, by = c("id", "t"))
#' }
is_valid_m_key <- function(dt, by){

Expand All @@ -536,7 +538,6 @@ is_valid_m_key <- function(dt, by){
FALSE
}

# Q: Do we document and test this function?

check_suffixes <- function(suffixes) {

Expand Down
Loading

0 comments on commit 5e4e92c

Please sign in to comment.