Skip to content

csvsoundsystem/Rtreasuryio

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
R
 
 
 
 
 
 
 
 

Rtreasuryio

Access treasury.io from R

This is a package consisting of a single, simple function for submitting SQL queries to treasury.io from R. While you could simply copy-and-paste the function from script-to-script, this makes it quicker and easier to get up and running!

Installation

library('devtools')
install_github('Rtreasuryio', 'csvsoundsystem')
library('Rtreasuryio')

Example

# Operating cash balances for May 22, 2013
sql <- 'SELECT * FROM "t1" WHERE "date" = \'2013-05-22\';'
treasuryio(sql)

Source Code

library(plyr)
library(utils)
library(RJSONIO)
library(RCurl)

treasuryio <- function(sql) {
  url = paste('http://api.treasury.io/cc7znvq/47d80ae900e04f2/sql/?q=', URLencode(sql), sep = '')
  handle <- getCurlHandle()
  body <- getURL(url, curl = handle)
  if (200 == getCurlInfo(handle)$response.code) {
    ldply(
      fromJSON(body),
      function(row) {as.data.frame(t(row))}
    )
  } else {
    stop(body)
  }
}

About

Query treasury.io from R

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages