Learn R Programming

automerge

Conflict-free data synchronization for R

automerge brings Automerge CRDTs (Conflict-free Replicated Data Types) to R, enabling automatic merging of concurrent changes across distributed systems without conflicts. Work offline, collaborate in real-time, or sync across platforms—changes merge automatically.

Why Automerge?

Traditional approaches to distributed data either require a central server to coordinate changes or force developers to write complex conflict resolution logic. Automerge’s CRDT technology automatically merges concurrent changes with mathematical guarantees, eliminating the need for coordination and making distributed systems dramatically simpler.

Quick Example

library(automerge)

# Two researchers working independently
alice <- am_create()
alice$experiment <- "trial_001"
alice$temperature <- 23.5
am_commit(alice, "Alice's data")

bob <- am_create()
bob$experiment <- "trial_002"
bob$humidity <- 65
am_commit(bob, "Bob's data")

# Later, sync with zero conflicts
am_sync(alice, bob)
alice
#> <Automerge Document>
#> Actor: 430ffacff3ae9ece2c50d476120588d1 
#> Root keys: 3 
#> Keys: experiment, humidity, temperature
bob
#> <Automerge Document>
#> Actor: abb94fd55ba7c10623aa19f30ae871b1 
#> Root keys: 3 
#> Keys: experiment, humidity, temperature

Key Features

  • Familiar R syntax: Work with CRDT documents like regular R lists
  • Rich data types: Maps, lists, text objects, counters, and timestamps
  • Collaborative text editing: Cursors and marks for rich text applications
  • Bidirectional sync: High-level am_sync() or low-level protocol access
  • Offline-first: Make changes offline, merge when connected
  • Cross-platform: Interoperates with JavaScript and other Automerge implementations
  • Zero dependencies: Only base R required at runtime

Installation

install.packages("automerge")

Building from source requires Rust >= 1.84 (rustup.rs) and CMake >= 3.25 (included in Rtools43+ on Windows).

Documentation

External Resources

Related Projects

  • autosync - automerge-repo compatible R sync server
  • autoedit - Collaborative code editor widget for R and Shiny

License

MIT License. See LICENSE for details. This package includes the automerge-c library (also MIT licensed)

Copy Link

Version

Install

install.packages('automerge')

Version

0.2.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Charlie Gao

Last Published

February 5th, 2026

Functions in automerge (0.2.1)

am_marks

Get all marks in a text object
am_get_heads

Get the current heads of a document
am_get_path

Navigate deep structures with path
am_marks_at

Get marks at a specific position
am_insert

Insert a value into an Automerge list
am_load

Load an Automerge document from binary format
am_rollback

Roll back pending operations
am_list

Create an Automerge list
am_put_path

Set value at path
am_set_actor

Set the actor ID of a document
am_save

Save an Automerge document to binary format
am_mark

Create a mark on a text range
am_map

Create an Automerge map
am_put

Put a value into an Automerge map or list
am_merge

Merge changes from another document
am_length

Get the length of an Automerge map or list
am_keys

Get all keys from an Automerge map
length.am_object

Get length of Automerge object
as.character.am_text

Convert text object to character string
as.list.am_doc

Convert document root to R list
am_text

Create an Automerge text object
am_text_splice

Splice text in a text object
am_sync_encode

Generate a sync message
am_uint64

Create an unsigned 64-bit integer value
am_text_update

Update text content
extract-am_doc

Extract from Automerge document root
extract-am_object

Extract from Automerge object
print.am_object

Print Automerge object (fallback for unknown types)
am_values

Get all values from a map or list
am_sync_decode

Receive and apply a sync message
automerge-constants

Automerge Constants
print.am_text

Print Automerge text object
am_sync

Bidirectional synchronization
automerge-package

automerge: R Bindings for 'Automerge' 'CRDT' Library
print.am_uint64

Print Automerge unsigned 64-bit integer
am_sync_state_new

Create a new sync state
names.am_doc

Get names from document root
names.am_map

Get names from Automerge map object
print.am_counter

Print Automerge counter
as.list.am_list

Convert Automerge list to R list
am_text_content

Get text content from a text object
from_automerge

Convert Automerge document to R list
print.am_syncstate

Print Automerge sync state
length.am_doc

Get length of document root
replace-am_doc

Replace in Automerge document root
as.list.am_map

Convert Automerge map to R list
replace-am_object

Replace in Automerge object
print.am_map

Print Automerge map object
print.am_list

Print Automerge list object
str.am_doc

Display the structure of an Automerge document
as_automerge

Convert R list to Automerge document
print.am_cursor

Print Automerge cursor
print.am_doc

Print Automerge document
as.list.am_text

Convert Automerge text to character string
am_create

Create a new Automerge document
am_counter

Create an Automerge counter
am_delete

Delete a key from a map or element from a list
am_commit

Commit pending changes
am_counter_increment

Increment a counter value
am_cursor

Create a cursor at a position in a text object
am_cursor_position

Get the current position of a cursor
am_get_change_by_hash

Get a specific change by its hash
am_get_changes

Get changes since specified heads
am_apply_changes

Apply changes to a document
am_delete_path

Delete value at path
am_get_actor_hex

Get the actor ID as a hex string
am_close

Close an Automerge document
am_get_actor

Get the actor ID of a document
am_fork

Fork an Automerge document
am_get

Get a value from an Automerge map or list
am_get_last_local_change

Get the last change made by the local actor
am_get_history

Get document history
am_get_changes_added

Get changes in one document that are not in another