The RProtobuf package provides R with facilities to read, write, ... Google Protocol Buffers files and messages.

About Protocol Buffers

What are Protocol Buffers? A quote from the overview page:
Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. You can even update your data structure without breaking deployed programs that are compiled against the "old" format.
and later on that page:
Protocol buffers are now Google's lingua franca for data --- at the time of writing, there are 48,162 different message types defined in the Google code tree across 12,183 .proto files. They're used both in RPC systems and for persistent storage of data in a variety of storage systems.

Protocol Buffers have native support for C++, Java and Python -- via official implementations provided by Google. This binding for R is one of a number of Third Party Addons for languages ranging from pure C to Clojure, Erlang, Haskell, Perl, Ruby and more. But until now, no R.

Sample usage

The standard 'person' in 'addressbook' example from the Google documentation can be recast in R as follows:
R> library( RProtoBuf )                      ## load the package
R> readProtoFiles( "addressbook.proto" )     ## acquire protobuf information
R> bob <- new( tutorial.Person,              ## create new object
+   email = "bob@example.com",
+   name = "Bob",
+   id = 123 )
R> writeLines( bob$toString() )              ## serialize to stdout
name: "Bob"
id: 123
email: "bob@example.com"

R> bob$email                                 ## access and/or override
[1] "bob@example.com"
R> bob$id <- 5
R> bob$id
[1] 5

R> serialize( bob, "person.pb" )             ## serialize to compact binary format


Development versions of the RProtoBuf package were available until late 2013 via R-Forge, and are now available at GitHub.

Released packages are available via CRAN. We currently do not have Windows or OS X versions as someone would need to help CRAN with binary versions of the C++ libraries for these platforms. We plan to help with Windows 'soon', time permitting.

Sources and documentation are also available via the local archive.


The package manual and a draft version of a package vignette are available, as is a 'quick' overview vignette and a unit test summary vignette.


RProtoBuf is copyright (C) 2009 - 2013 by Romain Francois and Dirk Eddelbuettel, and (C) 2011 - 2013 by Romain Francois, Dirk Eddelbuettel and Murray Stokely.


RProtoBuf is licensed under the GNU GPL version 2 or later. The Protocol Buffers library is released by Google under the New BSD license.

Last modified: Sun Dec 1 08:50:51 CST 2013