Daff
Diff, patch and merge for data.frames, see http://paulfitz.github.io/daff/
Install / Use
/learn @edwindj/DaffREADME
Daff: diff, patch and merge for data.frames
daff is an R package that can find difference in values between
data.frames, store this difference, render it and apply this
difference to patch a data.frame. It can also merge two versions of a
data.frame having a common parent. It wraps the
daff.js library using the
V8 package.
The diff format is described in https://paulfitz.github.io/daff-doc/spec.html.
Functions:
- diff:
diff_data - patch:
patch_data - write/read diff:
read_diffandwrite_diff - render to html:
render_diff - merge two tables based on a same version:
merge_data
Installation
You can install the development version of daff from GitHub with:
# install.packages("devtools")
devtools::install_github("edwindj/daff")
Usage
diff_data
Calculate the difference between a reference and a changed data.frame
library(daff)
y <- iris[1:3,]
x <- y
x <- head(x,2) # remove a row
x[1,1] <- 10 # change a value
x$hello <- "world" # add a column
x$Species <- NULL # remove a column
patch <- diff_data(y, x)
# write a patch to disk
write_diff(patch, "patch.csv")
render_diff(patch) will generate the following HTML page:
patch_data
Patch a data.frame using a diff generated with diff_data.
# read a diff from disk
patch <- read_diff("patch.csv")
# apply patch
y_patched <- patch_data(y, patch)
merge_data
Merge two data.frames that have diverged from a common parent
data.frame.
parent <- a <- b <- iris[1:3,]
a[1,1] <- 10
b[2,1] <- 11
# succesful merge
merge_data(parent, a, b)
parent <- a <- b <- iris[1:3,]
a[1,1] <- 10
b[1,1] <- 11
# conflicting merge (both a and b change same cell)
merged <- merge_data(parent, a, b)
merged #note the conflict
#find out which rows contain a conflict
which_conflicts(merged)
Related Skills
node-connect
341.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.4kCommit, push, and open a PR
