Skip to content

Instantly share code, notes, and snippets.

@drw
drw / ckan-sql-example.R
Last active Oct 19, 2018
R script showing how to convert a string field to an integer and then use it in the WHERE clause of a SQL query.
View ckan-sql-example.R
if(!require(ckanr)){ # If the CKAN wrapper isn't already installed,
install.packages("ckanr") # install it.
}
library(ckanr)
ckanr_setup(url = "https://data.wprdc.org/") # Set data.wprdc.org as the default URL.
query_8_to_9 = paste0('SELECT * FROM "47350364-44a8-4d15-b6e0-5f79ddff9367" WHERE "ward" >= ',"'8'",' AND "ward" <= ',"'9'")
# This query selects from the table with name "47350364-44a8-4d15-b6e0-5f79ddff9367"
View example_CKAN_query.R
# This script shows how to get data from a private CKAN repository
# using the datastore_search API endpoint. It then pulls the data
# records out of the JSON response and casts fields to particular
# types, renaming and manipulating some along the way.
library(jsonlite)
library(httr)
source("authentication.R") # This file should define CKAN_API_key.
# By putting this in a separate file, you can easily prevent
# it from being added to your git repository. (Just add the line
@drw
drw / keybase.md
Created Apr 11, 2014
Keybase.io proof
View keybase.md

Keybase proof

I hereby claim:

  • I am drw on github.
  • I am drw (https://keybase.io/drw) on keybase.
  • I have a public key whose fingerprint is 8E28 E4F7 E8C0 3B19 7FE6 108F F14A 934F 969B 07B0

To claim this, I am signing this object:

You can’t perform that action at this time.