-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished memphis311 post, published from drafts.
- Loading branch information
Showing
3 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"hash": "3a1f5569160bda757bd0cfdb1d1c1cfd", | ||
"result": { | ||
"engine": "knitr", | ||
"markdown": "---\ntitle: \"An R package for getting `memphis311` Data\"\ndate: \"2024-03-21\"\nimage: \"img/vacant-house.jpeg\"\ndescription: \"Quickly access Memphis's 311 dataset API.\"\ncategories:\n - R\n - housing\n - memphis\n - httr\n - api\n - code-enforcement\n---\n\n\n## Intro\n\nMemphis code enforcement data is available in the [Service Requests since 2016](https://data.memphistn.gov/dataset/Service-Requests-since-2016/hmd4-ddta/about_data) dataset from Memphis Data Hub. The `memphis311` package was created as a simple way to access the dataset.\n\nYou can install the package from github and access it like so:\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# devtools::install_github(\"sj-io/memphis311\")\nlibrary(memphis311)\n```\n:::\n\n\n## `get_311`\n\nThe package currently contains one function, `get_311()`. There are no default parameters; you can specify a variable for any column in the dataset. \n\nIf you do not specify any columns, the package will call for a csv file containing all rows. Note that this will take a long time, as the dataset has over 2 million rows. \n\n\n::: {.cell}\n\n```{.r .cell-code}\nservice_requests <- get_311(\n department = \"code enforcement\", \n creation_date = \"2024-03-09\",\n request_type = \"CE-Substandard,Derelict Struc\"\n ) \n\ndplyr::glimpse(service_requests)\n```\n\n::: {.cell-output .cell-output-stdout}\n\n```\nRows: 20\nColumns: 30\n$ division <chr> \"Public Works\", \"Public Works\", \"Public Works\", \"P…\n$ department <chr> \"CODE ENFORCEMENT\", \"CODE ENFORCEMENT\", \"CODE ENFO…\n$ group_name <chr> \"MEMPHIS\", \"MEMPHIS\", \"MEMPHIS\", \"MEMPHIS\", \"MEMPH…\n$ category <chr> \"Inspection-Structures\", \"Inspection-Structures\", …\n$ ce_category <chr> \"VIOLATION (S)\", NA, \"VIOLATION (S)\", \"VIOLATION (…\n$ request_type <chr> \"CE-Substandard,Derelict Struc\", \"CE-Substandard,D…\n$ incident_type_id <chr> \"10409\", \"10409\", \"10409\", \"10409\", \"10409\", \"1040…\n$ incident_number <chr> \"50016200\", \"50016209\", \"50016210\", \"50016211\", \"5…\n$ incident_id <chr> \"50016200\", \"50016209\", \"50016210\", \"50016211\", \"5…\n$ resolution_code <chr> \"JW-RH\", NA, \"JW-DM\", \"JW-RH\", \"CVOID\", \"JW-RH\", \"…\n$ resolution_summary <chr> NA, NA, \"PROPERTY WILL BE WRITTEN UP FOR CONDEMNAT…\n$ summary_1 <chr> \"Not Applicable\", \"Not Applicable\", \"Not Applicabl…\n$ request_status <chr> \"In Progress\", \"Open\", \"In Progress\", \"In Progress…\n$ request_priority <chr> \"Low\", \"Low\", \"Low\", \"Low\", \"Low\", \"Low\", \"Low\", \"…\n$ creation_date <chr> \"2024-03-09T07:27:09.000\", \"2024-03-09T08:02:04.00…\n$ reported_date <chr> \"2024-03-09T07:25:00.000\", \"2024-03-09T08:00:00.00…\n$ last_update_date <chr> \"2024-03-09T08:42:43.000\", \"2024-03-09T08:03:13.00…\n$ followup_date <chr> \"2024-05-01T11:00:00.000\", \"2024-03-23T11:00:00.00…\n$ sr_creation_channel <chr> \"WEB\", \"WEB\", \"WEB\", \"WEB\", \"WEB\", \"WEB\", \"WEB\", \"…\n$ created_by_user <chr> \"Sa_GISIdentitystore\", \"Sa_GISIdentitystore\", \"Sa_…\n$ last_updated_by <chr> \"Esri_Anonymous\", \"Esri_Anonymous\", \"Esri_Anonymou…\n$ parcel_id <chr> \"047008 00010\", \"048022 00040\", \"048020 00017\",…\n$ full_address <chr> \"2155 GOFF AVE\", \"1596 WILSON ST\", \"1488 SOUTH AVE…\n$ location_1 <chr> \"2155 GOFF AVE\", \"1596 WILSON ST\", \"1488 SOUTH AVE…\n$ address1 <chr> \"2155 GOFF AVE\", \"1596 WILSON ST\", \"1488 SOUTH AVE…\n$ city <chr> \"MEMPHIS\", \"MEMPHIS\", \"MEMPHIS\", \"MEMPHIS\", \"MEMPH…\n$ state <chr> \"Tennessee\", \"Tennessee\", \"Tennessee\", \"Tennessee\"…\n$ postal_code <chr> \"38114\", \"38106\", \"38106\", \"38106\", \"38106\", \"3811…\n$ target_block <chr> \"116\", \"117\", \"117\", \"117\", \"117\", \"116\", \"12\", \"1…\n$ location1 <df[,2]> <data.frame[20 x 2]>\n```\n\n\n:::\n:::\n\n\n## Important notes\n\nAny of the columns in the dataset can be selected, but only basic queries are available right now. This means you can call a specific value for a variable (`department = \"code enforcement\"`), including a specific date. \n\nFor more complex queries, I recommend using the [`RSocrata`](https://github.com/Chicago/RSocrata) package. This package is meant to be a simple way to access Memphis's code enforcement data.\n\nThe main benefits of this package are:\n\n- The Memphis 311 API url is included in the package.\n- All date columns in the dataset are shortened to YYYY-MM-DD format, so you don't need to include times.\n- Text columns will make case-insensitive matches, so it will return requests where `department` is \"CODE ENFORCEMENT\" or \"Code Enforcement\".\n- Columns are sorted into a more logical order than alphabetical. Locations and times are grouped together so more relevant data can quickly be found.\n\nIn the future I hope to add more flexibility for querying (especially dates), and helpers for tidying the dataset to find relevant information for housing research.\n", | ||
"supporting": [], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,55 @@ | ||
--- | ||
title: "`memphis311`: An R package for getting Memphis 311 Requests" | ||
title: "An R package for getting `memphis311` Data" | ||
date: "2024-03-21" | ||
draft: true | ||
image: "img/vacant-house.jpeg" | ||
description: "Quickly access Memphis's 311 dataset API." | ||
categories: | ||
- R | ||
- housing | ||
- memphis | ||
- httr | ||
- api | ||
- code-enforcement | ||
--- | ||
|
||
Blah blah blah | ||
## Intro | ||
|
||
Memphis code enforcement data is available in the [Service Requests since 2016](https://data.memphistn.gov/dataset/Service-Requests-since-2016/hmd4-ddta/about_data) dataset from Memphis Data Hub. The `memphis311` package was created as a simple way to access the dataset. | ||
|
||
You can install the package from github and access it like so: | ||
|
||
```{r load} | ||
# devtools::install_github("sj-io/memphis311") | ||
library(memphis311) | ||
``` | ||
|
||
## `get_311` | ||
|
||
The package currently contains one function, `get_311()`. There are no default parameters; you can specify a variable for any column in the dataset. | ||
|
||
If you do not specify any columns, the package will call for a csv file containing all rows. Note that this will take a long time, as the dataset has over 2 million rows. | ||
|
||
```{r get311Example, eval=TRUE, echo=TRUE, message=FALSE} | ||
service_requests <- get_311( | ||
department = "code enforcement", | ||
creation_date = "2024-03-09", | ||
request_type = "CE-Substandard,Derelict Struc" | ||
) | ||
dplyr::glimpse(service_requests) | ||
``` | ||
|
||
## Important notes | ||
|
||
Any of the columns in the dataset can be selected, but only basic queries are available right now. This means you can call a specific value for a variable (`department = "code enforcement"`), including a specific date. | ||
|
||
For more complex queries, I recommend using the [`RSocrata`](https://github.com/Chicago/RSocrata) package. This package is meant to be a simple way to access Memphis's code enforcement data. | ||
|
||
The main benefits of this package are: | ||
|
||
- The Memphis 311 API url is included in the package. | ||
- All date columns in the dataset are shortened to YYYY-MM-DD format, so you don't need to include times. | ||
- Text columns will make case-insensitive matches, so it will return requests where `department` is "CODE ENFORCEMENT" or "Code Enforcement". | ||
- Columns are sorted into a more logical order than alphabetical. Locations and times are grouped together so more relevant data can quickly be found. | ||
|
||
In the future I hope to add more flexibility for querying (especially dates), and helpers for tidying the dataset to find relevant information for housing research. |