R4CouchDB is part of the cran cosmos so the package can be installed by:
The example presumes a running CouchDB on http://localhost:5984. The plan is to store some data to a CouchDB document get it back and make a plot (some eye candy) out of it.
At first load the R4CouchDB package as usual:
Then we generate the connection or interface list (here assigned to the variable cdb) by:
cdb makes some default assumptions such as:
Now straight forward: we make a database http://localhost:5984/r-example, load some fancy volcano data, and write the data (plus some demo info) to a new database document:
We now make the plot of the volcano with the data from the database. Getting back the data is done with:
regenerate the volcano matrix from the result of the database query (cdoc) by:
and here we are:
Finally we can store the diagram as png in the database document as an attachment by:
An easy interface to CouchDB from R. Targeted at CouchDB v2+, but much of the package should work with older versions.
Load the package
Make a client
Ping the server
Create a new database
List your databases
Create a document
Query the database
Return all cats that are red
Bulk create documents
Create documents in bulk from a data.frame, list, or JSON as a character string.