Last active
December 21, 2022 23:18
-
-
Save kmasiello/0b2ca8bb89bcf0692a074da5d9557236 to your computer and use it in GitHub Desktop.
Use `diffdf` to identify differences between two versions of a pinned data frame on Connect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Also see pin_unique helper function at https://gist.github.com/kmasiello/2d47c88617339fa69c85fa3ed8905e86 to only pin if the data frame is changed from the previous version. | |
library(pins) | |
board <- board_rsconnect() | |
# Get version diffs | |
# Parameters for `pin_compare` | |
# board = a rsconnect board object defined by board_rsconnect() | |
# pin_name = the name of the pinned object on Connect | |
# ref_vers = the reference version of a pin to compare. By default, the second-most recent version | |
# compare_vers = the comparison version of a pin. By default, the most-recent version of a pin | |
pin_compare <- function(board, pin_name, ref_vers=2, compare_vers=1){ | |
reference_version_id <- pin_versions(board, {{pin_name}})$version[ref_vers] | |
compare_version_id <- pin_versions(board, {{pin_name}})$version[compare_vers] | |
reference <- pin_read(board, {{pin_name}}, version = reference_version_id) | |
comparison <- pin_read(board, {{pin_name}}, version = compare_version_id) | |
diffdf(reference, comparison) | |
} | |
# Compare versions | |
pin_compare(board, "katie.masiello/ref_pin", 1, 2) | |
pin_compare(board, "katie.masiello/ref_pin", 2, 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment