Conversation
In Windows, this avoids that pattern mismatches occur between root and file. Before, this could lead to not removing the root part from the returned vector.
Co-authored-by: ThierryO <446636+ThierryO@users.noreply.github.com>
Co-authored-by: ThierryO <446636+ThierryO@users.noreply.github.com>
Co-authored-by: ThierryO <446636+ThierryO@users.noreply.github.com>
Co-authored-by: ThierryO <446636+ThierryO@users.noreply.github.com>
## Description This PR adds some fixes related to the return value of `rename_variable()`. - In the documentation, the description of the return value was wrong (NULL). - On Windows it has been observed that the root remains included in the result, despite `remove_root()` was called. During debugging on Windows, it was seen that Windows-specific pattern mismatches occurred between the `root` and `file` arguments of `remove_root()`. These could be "\\\\" vs. "/" as well as user directory abbreviations. Applying `normalizePath()` on both inputs of `remove_root()` before calling the latter, similar to the way this is handled in `write_vc()` (where the problem doesn't pop up), solved it. - A test has been added to verify that the root is not part of the resulting file vector. I'm pushing this in two steps, hoping to see failure of the tests in Windows first, then succes after adding the commit that fixes behaviour.
Co-authored-by: ThierryO <446636+ThierryO@users.noreply.github.com>
Co-authored-by: ThierryO <446636+ThierryO@users.noreply.github.com>
Co-authored-by: ThierryO <446636+ThierryO@users.noreply.github.com>
Co-authored-by: ThierryO <446636+ThierryO@users.noreply.github.com>
Yaml doesn't store named vectors. Therefore sort the convert functions.
…mations (#84) ## Description Implements column-level round-trip transformations. The `convert` argument allows specifying functions to transform data before storage and reverse the transformation on read. **Implementation:** - `convert` is a named list mapping column names to transformation specs - Each spec: `c(write = "package::function", read = "package::function")` - Write conversions applied before `meta()`, read conversions after `reinstate()` - Conversion metadata stored in YAML under `..generic$convert` - Metadata hash recalculated after adding convert to ensure integrity - Convert spec added to returned data.frame attributes **Validation:** - Verifies column names exist - Checks package availability via `requireNamespace()` - Validates function existence in specified package - Change detection integrated with `compare_meta()` for strict mode - Refactored validation logic into helper functions to meet cyclomatic complexity limits **Files modified:** - `R/utils.R`: `validate_convert()` and helper functions (`validate_convert_structure()`, `validate_convert_element()`, `validate_convert_function()`), plus `apply_convert()` - `R/write_vc.R`: Added convert parameter, validation, storage, hash recalculation, and change detection - `R/read_vc.R`: Read and apply conversions from metadata - `tests/testthat/test_h_convert.R`: 10 test cases covering validation, conversions, backward compatibility - `vignettes/convert.Rmd`: Comprehensive vignette with examples and use cases - `vignettes/data_package.Rmd`: Vignette documenting the `data_package()` function - `NEWS.md`: Feature documentation ## Related Issue Addresses issue #81 ## Example ```r library(git2rdata) data <- data.frame( text = c("hello", "world"), number = 1:2 ) # Transform text to uppercase for storage, lowercase on read write_vc( data, "mydata", root = ".", sorting = "number", convert = list( text = c( write = "base::toupper", read = "base::tolower" ) ), digits = 6 ) # TSV file contains: "HELLO", "WORLD" result <- read_vc("mydata", root = ".") result$text # Returns: "hello", "world" attr(result, "convert") # Contains conversion spec ``` Multiple columns supported: ```r convert = list( col1 = c(write = "pkg1::func1", read = "pkg1::func2"), col2 = c(write = "pkg2::func3", read = "pkg2::func4") ) ``` See `vignette("convert", package = "git2rdata")` for detailed usage examples. <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/ropensci/git2rdata/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix #81