Last active
August 29, 2015 14:20
-
-
Save jeroen/067b9e308af93ebd19f7 to your computer and use it in GitHub Desktop.
dat in R
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
# If you are running beta version, you might need to symlink 'dat-beta' to 'dat' | |
# Dependencies | |
library(jsonlite) | |
data("diamonds", package = "ggplot2") | |
# Initiate the dat repo | |
setwd(tempdir()) | |
system2("dat", "init") | |
# Add 1k lines of data | |
stream_out(diamonds[1:100,], pipe("dat add -")) | |
head1 <- readLines(pipe("dat heads")) | |
out <- stream_in(pipe("dat cat")) | |
View(out$value) | |
# Add few more lines | |
stream_out(diamonds[101,], pipe("dat add -")) | |
stream_out(diamonds[102,], pipe("dat add -")) | |
stream_out(diamonds[103,], pipe("dat add -")) | |
head2 <- readLines(pipe("dat heads")) | |
out <- stream_in(pipe("dat cat")) | |
View(out$value) | |
# Checkout diff | |
diffs <- stream_in(pipe(paste("dat diff", head1, head2))) | |
diffs$key | |
diffs$versions | |
# Go back to old version | |
system2("dat", c("checkout", head1)) | |
olddata <- stream_in(pipe("dat cat")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment