Skip to content

Commit

Permalink
finalize reame
Browse files Browse the repository at this point in the history
  • Loading branch information
concannon committed Apr 25, 2019
1 parent 21bc57e commit 014c967
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 16 deletions.
40 changes: 33 additions & 7 deletions .Rproj.user/B8DACF1A/console06/37FAB866
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
]0;/home/connor/CookCo]0;connor@datasci-1: ~/CookCoconnor@datasci-1:~/CookCo$ ]0;connor@datasci-1: ~/CookCoconnor@datasci-1:~/CookCo$ ls
CookCo.Rproj
]0;/home/connor/CookCo]0;connor@datasci-1: ~/CookCoconnor@datasci-1:~/CookCo$ sudo mkdidr r data
[sudo] password for connor:
]0;/home/connor/CookCo]0;connor@datasci-1: ~/CookCoconnor@datasci-1:~/CookCo$ ls
CookCo.Rproj data

]0;/home/connor/CookCo]0;connor@datasci-1: ~/CookCoconnor@datasci-1:~/CookCo$ ls -l
total 8
-rw-r--r-- 1 connor connor 205 Feb 20 10:28 CookCo.Rproj
Expand Down Expand Up @@ -1002,4 +997,35 @@ Total 20 (delta 9), reused 0 (delta 0)
remote: Resolving deltas: 0% (0/9) remote: Resolving deltas: 11% (1/9) remote: Resolving deltas: 22% (2/9) remote: Resolving deltas: 33% (3/9) remote: Resolving deltas: 44% (4/9) remote: Resolving deltas: 55% (5/9) remote: Resolving deltas: 66% (6/9) remote: Resolving deltas: 77% (7/9) remote: Resolving deltas: 88% (8/9) remote: Resolving deltas: 100% (9/9) remote: Resolving deltas: 100% (9/9), completed with 9 local objects.
To https://github.com/concannon/CookCo.git
ee4ebee..135010a master -> master
]0;/home/connor/CookCo]0;connor@datasci-1: ~/CookCoconnor@datasci-1:~/CookCo$
]0;/home/connor/CookCo]0;connor@datasci-1: ~/CookCoconnor@datasci-1:~/CookCo$ ## Report
]0;/home/connor/CookCo]0;connor@datasci-1: ~/CookCoconnor@datasci-1:~/CookCo$ ## Report
^C
]0;/home/connor/CookCo]0;connor@datasci-1: ~/CookCoconnor@datasci-1:~/CookCo$ ^C
]0;/home/connor/CookCo]0;connor@datasci-1: ~/CookCoconnor@datasci-1:~/CookCo$ ls
CookCo.Rproj Output data media readme.html readme.md readme.rmd scripts
]0;/home/connor/CookCo]0;connor@datasci-1: ~/CookCoconnor@datasci-1:~/CookCo$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: .Rproj.user/B8DACF1A/console06/37FAB866
modified: .Rproj.user/B8DACF1A/console06/37FAB866.env
modified: .Rproj.user/B8DACF1A/console06/INDEX001
modified: .Rproj.user/B8DACF1A/sources/prop/37B80BDF
modified: .Rproj.user/B8DACF1A/sources/prop/INDEX
modified: .Rproj.user/shared/notebooks/412E6F4C-By Screen Year/1/s/chunks.json
modified: .Rproj.user/shared/notebooks/paths
modified: Output/Reporting/By Screen Year.rmd
modified: readme.md

Untracked files:
(use "git add <file>..." to include in what will be committed)

media/CookCoDashboard.png
media/Rstudio.png
media/rmarkdown.png
media/shiny.jpeg

no changes added to commit (use "git add" and/or "git commit -a")
]0;/home/connor/CookCo]0;connor@datasci-1: ~/CookCoconnor@datasci-1:~/CookCo$ git add .
Expand Down
4 changes: 2 additions & 2 deletions .Rproj.user/B8DACF1A/console06/37FAB866.env
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"MAKE" : "make",
"OLDPWD" : "/home/connor",
"PAGER" : "/usr/bin/pager",
"PATH" : "/home/connor/.local/bin:/home/connor/bin:/home/connor/.local/bin:/home/connor/bin:/home/connor/.local/bin:/home/connor/bin:/home/connor/.local/bin:/home/connor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home:bin/msys-ssh-1000-18:/snap/bin:/home:bin/msys-ssh-1000-18:/home:bin/msys-ssh-1000-18:/home:bin/msys-ssh-1000-18:/home:bin/msys-ssh-1000-18:/home:bin/msys-ssh-1000-18",
"PATH" : "/home/connor/.local/bin:/home/connor/bin:/home/connor/.local/bin:/home/connor/bin:/home/connor/.local/bin:/home/connor/bin:/home/connor/.local/bin:/home/connor/bin:/home/connor/.local/bin:/home/connor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home:bin/msys-ssh-1000-18:/snap/bin:/home:bin/msys-ssh-1000-18:/home:bin/msys-ssh-1000-18:/home:bin/msys-ssh-1000-18:/home:bin/msys-ssh-1000-18:/home:bin/msys-ssh-1000-18:/home:bin/msys-ssh-1000-18",
"PROMPT_COMMAND" : "echo -ne \"\\033]0;${PWD/#${HOME}/~}\\007\"",
"PWD" : "/home/connor/CookCo",
"RMARKDOWN_MATHJAX_PATH" : "/usr/lib/rstudio-server/resources/mathjax-26",
Expand Down Expand Up @@ -52,7 +52,7 @@
"R_UNZIPCMD" : "/usr/bin/unzip",
"R_ZIPCMD" : "/usr/bin/zip",
"SED" : "/bin/sed",
"SHLVL" : "6",
"SHLVL" : "7",
"SSH_ASKPASS" : "rpostback-askpass",
"TAR" : "/bin/tar",
"TERM" : "xterm-256color",
Expand Down
2 changes: 1 addition & 1 deletion .Rproj.user/B8DACF1A/console06/INDEX001
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"allow_restart":true,"alt_buffer":false,"autoclose":1,"buffered_output":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","caption":"Terminal 1","channel_id":"4645","channel_mode":1,"child_procs":false,"cols":103,"cwd":"","exit_code":1,"handle":"37FAB866","interaction_mode":2,"max_output_lines":1000,"restarted":true,"rows":17,"shell_type":7,"show_on_output":false,"terminal_sequence":1,"title":"connor@datasci-1: ~/CookCo","track_env":true,"zombie":false}]
[{"allow_restart":true,"alt_buffer":false,"autoclose":1,"buffered_output":"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","caption":"Terminal 1","channel_id":"3704","channel_mode":1,"child_procs":false,"cols":103,"cwd":"~/CookCo","exit_code":null,"handle":"37FAB866","interaction_mode":2,"max_output_lines":1000,"restarted":true,"rows":17,"shell_type":7,"show_on_output":false,"terminal_sequence":1,"title":"/srv/shiny-server/CookCo","track_env":true,"zombie":false}]
2 changes: 1 addition & 1 deletion .Rproj.user/B8DACF1A/sources/prop/37B80BDF
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"chunk_output_type" : "console",
"cursorPosition" : "56,47",
"cursorPosition" : "75,0",
"scrollLine" : "0"
}
2 changes: 2 additions & 0 deletions .Rproj.user/B8DACF1A/sources/prop/INDEX
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
~%2FCookCo%2Freadme.rmd="92C474EE"
~%2FCookCo%2Frun%20cleanup.r="F9273DCE"
~%2FCookCo%2Fsample.R="E1D8F6E1"
~%2FCookCo%2Fscripts%2Fdispositions.r="66CA1FEB"
~%2FCookCo%2Fscripts%2Fdownload_data.r="82CD303E"
~%2FCookCo%2Fscripts%2Fjoin_files.R="30C8BD53"
~%2FCookCo%2Fscripts%2Frun%20cleanup.r="EECFE78A"
~%2FCookCo%2Fscripts%2Fsentences.r="A2EF4922"
~%2FCookCo%2Fsentences.r="F906023C"
~%2FTemplates%2FADA%20Assignment%2FADA%20Assignment.sql="F2D0E6CB"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"chunk_definitions":[],"doc_write_time":1554716586}
{"chunk_definitions":[],"doc_write_time":1554718129}
4 changes: 4 additions & 0 deletions .Rproj.user/shared/notebooks/paths
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
/home/connor/CookCo/Output/Reporting/By Screen Year.rmd="412E6F4C"
/home/connor/CookCo/readme.md="23833CBF"
/home/connor/CookCo/readme.rmd="4A79A435"
/home/connor/CookCo/scripts/dispositions.r="A3395CC"
/home/connor/CookCo/scripts/download_data.r="2C542DAF"
/home/connor/CookCo/scripts/join_files.R="BBC54212"
/home/connor/CookCo/scripts/run cleanup.r="D7ED5A7"
/home/connor/CookCo/scripts/sentences.r="57893EA"
/home/connor/Templates/ADA Assignment/ADA Assignment.sql="3DD80545"
/home/connor/Templates/By Screen Year/By Screen Year.rmd="54346FA5"
/home/connor/Templates/Sealed Cases/Sealed Cases.sql="EC86A91C"
/home/connor/Templates/doc today/DOC Over Date Period/DOC Over Date Period.sql="EB07687D"
/srv/shiny-server/CookCo/app.r="BEF265"
/srv/shiny-server/CookCo/app_setup.r="3693FCD3"
4 changes: 4 additions & 0 deletions Output/Reporting/By Screen Year.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ This report desribes `r n_distinct(d$CASE_PARTICIPANT_ID)` `r params$data` defen

```{r generic summary,echo=F,results='asis', eval = T}
#================
#Screen
#================
Expand Down
Binary file added media/CookCoDashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/Rstudio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/rmarkdown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/shiny.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 46 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This repository focuses on the process required to make this data 'tidy' using t


<p>
<img src="/media/Digital Ocean.png" width="1536" height="1024" />
<img src="/media/Digital Ocean.png"/>
</p>

This analysis took place on a [Digital Ocean](https://www.digitalocean.com/) data science droplet with default (2 Gb memory and 50 Gb of storage) specifications running Ubuntu 18.04. This droplet cost $10 per month. To generate reports and analyses using R, a handful of dependencies were required. The next section lists each installation and the commands that are required.
Expand Down Expand Up @@ -78,18 +78,60 @@ sudo sh -c 'echo "/var/swap.1 swap swap defaults 0 0 " >> /etc/fstab'
## Download Data

<p>
<img src="/media/Cook County Open Data Portal.png" />
<img src="/media/Cook County Open Data Portal.png"/>
</p>

The data is hosted on the [Cook County Government Open Data Portal](https://datacatalog.cookcountyil.gov/browse?tags=state%27s+attorney+case-level&sortBy=most_accessed), and can be downloaded manually via the browser. Alternatively, you can download the files programatically via the `download_data.r` file.

## Clean

The `scripts` folder contains a number of files that will clean each data set. The data sets downloaded from the Cook County Open Data Portal are:

## Join
* initiation
* intake
* disposition
* sentence

In many contexts, these files will evolve over time. For this project, these contain rudimentary logic to identify the top charge, reorder charges, and save clean datasets. Finally there is a script to join the files and save a final, cleaned dataset.

The `join_file` script also creates dummy variables for several fields to ease later reporting and summarizing.

**Important caveat: I have not validated the logic I used to tidy these datasets with anyone from the CCSAO. The repository is for demonstration purposes only and should not be interpreted as official or accurate CCSAO statistics.**

## Report

<p>
<img src="/media/rmarkdown.png"/>
</p>

The `output/Reporting` directory contains an RMarkdown file that will help generate a standardized report of cases, dispositions, and sentences by year. [RMarkdown](https://rmarkdown.rstudio.com/) is a framework to generate reports and ensure they are reproducible and standardized.

At the beginning of the file, this report expects the user to enter a charge type (in this case narcotics), which filters the data and generates intake and disposition statistics for only narcotics cases.

The bulk of this file is summarizing and formatting case processing statistics and readying them for presentation. If everything is installed, you can 'knit' the file by pressing `CTRL+SHIFT+K`, and the file will generate. If not, a sample report is included in the repository.


## Dashboard


<p>
<img src="/media/Shiny.jpeg"/>
</p>

The previous steps enabled me to create an interactive dashboard of case processing statistics, using the [Shiny](http://shiny.rstudio.com/) framework. This is also an R-based language, that extends the tidy mantra and makes analyses interactive. The Shiny package is very well documented, and the specifics about creating the dashboard are beyond the scope of this repository. In short, the developer is responsible for accepting user inputs and filtering or manipulating the dataset based on those inputs. A handful of thorough walkthroughs on Shiny are linked below.

* [Welcome to Shiny](https://shiny.rstudio.com/tutorial/written-tutorial/lesson1/)
* [Shiny Dashboard](https://rstudio.github.io/shinydashboard/)
* [Building Shiny Apps](https://deanattali.com/blog/building-shiny-apps-tutorial/)

The dashboard is available [at this link](http://178.128.232.146:3838/CookCo)


<p>
<img src="/media/CookCoDashboard.png"/>
</p>


## Conclusion

## Dashboard
Hopefully, this repository demonstrates one way to transform raw data into useable information for stakeholders. I hope that others can take the methods used in this brief demonstration and extend it in their own jurisdictions.

0 comments on commit 014c967

Please sign in to comment.