ojo is a package that assists Open Justice Oklahoma analysts to access and analyze court, jail, prison, and other data collected from various sources.
The pkgdown website for the ojo package can be found here.
Before installing, you’ll need to get a credentials file that will provide you access to the OJO database. After you have that, you can install the ojo package from GitHub with:
devtools::install_github("openjusticeok/ojo")
After installation, update it with:
ojo_reinstall()
To list all tables in the OJO database, use ojo_list_tables()
. Any
table that is split according to year/casetype is collapsed into the
general table in the output to this function. For instance, while you
would query the oscn_mins_2019SC
table to get minutes from small
claims (SC) cases filed in 2019, it appears here as oscn_mins_
to
avoid overwhelming the eyes.
library(ojo)
ojo_list_tables()
To see the variables and first 10 rows of a table, call ojo_tbl()
on
it:
ojo_tbl("oscn_crim_disps")
In many cases, you’ll only be interested in a particular county, time
period, and/or case type. You can now limit the data using the
filter()
function, then use ojo_collect()
to bring the pre-filtered
data into R.
d <- ojo_tbl("oscn_crim_disps") %>%
filter(court == "ROGERS", casetype == "CM", file_year == 2019) %>%
ojo_collect()
The first line points to the oscn_crim_disps
table (basically SELECT
\* FROM oscn_crim_disps
). The second line limits the query (WHERE
court = 'ROGERS' AND casetype = 'CM' AND file_year = 2019
), so you’re
only getting the data you want, not querying the entire table.
ojo_collect()
executes the query, creates a dataframe in R, and closes
the connection to the database (disconnect_ojo()
). This should mostly
eliminate the need for calling connect_ojo()
before querying and
disconnect_ojo()
afterward.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.