{"id":13558075,"url":"https://github.com/edwindj/daff","last_synced_at":"2025-05-14T07:42:30.841Z","repository":{"id":27437862,"uuid":"30915891","full_name":"edwindj/daff","owner":"edwindj","description":"Diff, patch and merge for data.frames, see  http://paulfitz.github.io/daff/","archived":false,"fork":false,"pushed_at":"2024-02-15T07:46:35.000Z","size":1851,"stargazers_count":152,"open_issues_count":12,"forks_count":18,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-31T15:27:21.559Z","etag":null,"topics":["daff","data","diff","r"],"latest_commit_sha":null,"homepage":"https://edwindj.github.io/daff/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edwindj.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-02-17T12:23:31.000Z","updated_at":"2025-03-22T08:13:24.000Z","dependencies_parsed_at":"2024-01-14T15:24:55.731Z","dependency_job_id":"0ac972ef-e311-4edc-91ec-d40a265d4655","html_url":"https://github.com/edwindj/daff","commit_stats":{"total_commits":177,"total_committers":3,"mean_commits":59.0,"dds":"0.44067796610169496","last_synced_commit":"d4323dedac81e828f38b7ecfc4147066c418e938"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwindj%2Fdaff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwindj%2Fdaff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwindj%2Fdaff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edwindj%2Fdaff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edwindj","download_url":"https://codeload.github.com/edwindj/daff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247002448,"owners_count":20867464,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["daff","data","diff","r"],"created_at":"2024-08-01T12:04:43.864Z","updated_at":"2025-04-03T12:31:39.062Z","avatar_url":"https://github.com/edwindj.png","language":"R","funding_links":[],"categories":["R","data","其他_机器学习与深度学习"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n\u003c!-- badges: start --\u003e\n\n![version](http://www.r-pkg.org/badges/version/daff)\n[![R-CMD-check](https://github.com/edwindj/daff/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/edwindj/daff/actions/workflows/R-CMD-check.yaml)\n![downloads](http://cranlogs.r-pkg.org/badges/daff)\n\n\u003c!-- badges: end --\u003e\n\n# Daff: diff, patch and merge for data.frames\n\ndaff is an R package that can find difference in values between\n`data.frames`, store this difference, render it and apply this\ndifference to patch a `data.frame`. It can also merge two versions of a\n`data.frame` having a common parent. It wraps the\n[daff.js](http://paulfitz.github.io/daff/) library using the\n[V8](https://github.com/jeroen/v8) package.\n\nThe diff format is described in\n\u003chttps://paulfitz.github.io/daff-doc/spec.html\u003e.\n\n\nFunctions:\n\n- diff: `diff_data`\n- patch: `patch_data`\n- write/read diff: `read_diff` and `write_diff`\n- render to html: `render_diff`\n- merge two tables based on a same version: `merge_data`\n\n\n## Installation\n\nYou can install the development version of daff from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"edwindj/daff\")\n```\n\n# Usage\n\n## diff_data\n\nCalculate the difference between a reference and a changed `data.frame`\n\n``` r\nlibrary(daff)\ny \u003c- iris[1:3,]\nx \u003c- y\n\nx \u003c- head(x,2) # remove a row\nx[1,1] \u003c- 10 # change a value\nx$hello \u003c- \"world\"  # add a column\nx$Species \u003c- NULL # remove a column\n\npatch \u003c- diff_data(y, x)\n\n# write a patch to disk\nwrite_diff(patch, \"patch.csv\")\n```\n\n`render_diff(patch)` will generate the following HTML page:\n\n\u003cfigure\u003e\n\u003cimg src=\"man/figures/render_diff.png\" title=\"render_diff\" alt=\"render_diff\" /\u003e\n\u003cfigcaption aria-hidden=\"true\"\u003erender_diff\u003c/figcaption\u003e\n\u003c/figure\u003e\n\n## patch_data\n\nPatch a `data.frame` using a diff generated with `diff_data`.\n\n``` r\n# read a diff from disk\npatch \u003c- read_diff(\"patch.csv\")\n\n# apply patch\ny_patched \u003c- patch_data(y, patch)\n```\n\n## merge_data\n\nMerge two `data.frame`s that have diverged from a common parent\n`data.frame`.\n\n``` r\nparent \u003c- a \u003c- b \u003c- iris[1:3,]\na[1,1] \u003c- 10\nb[2,1] \u003c- 11\n# succesful merge\nmerge_data(parent, a, b)\n\nparent \u003c- a \u003c- b \u003c- iris[1:3,]\na[1,1] \u003c- 10\nb[1,1] \u003c- 11\n# conflicting merge (both a and b change same cell)\nmerged \u003c- merge_data(parent, a, b)\nmerged #note the conflict\n\n#find out which rows contain a conflict\nwhich_conflicts(merged)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwindj%2Fdaff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedwindj%2Fdaff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedwindj%2Fdaff/lists"}