This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
library(sqldf)
## Loading required package: gsubfn
## Loading required package: proto
## Warning in doTryCatch(return(expr), name, parentenv, handler): unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so':
## dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 6): Library not loaded: /usr/X11/lib/libSM.6.dylib
## Referenced from: /Library/Frameworks/R.framework/Resources/modules//R_X11.so
## Reason: image not found
## Could not load tcltk. Will use slower R code instead.
## Loading required package: RSQLite
## Loading required package: DBI
library(readr)
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.2.5
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tibble)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.2.4
library(scales)
## Warning: package 'scales' was built under R version 3.2.3
##
## Attaching package: 'scales'
## The following objects are masked from 'package:readr':
##
## col_factor, col_numeric
county_spending <- read.csv("Desktop/Course/R/Data Wrangling with R (BANA 8090)/County_Spending.csv", stringsAsFactors = FALSE)
names(county_spending)
## [1] "Fiscal.Year.Period" "Fiscal.Year"
## [3] "Service" "Department"
## [5] "Program" "Fund"
## [7] "Category" "Expense.Category"
## [9] "Account.Code" "Invoice.Description"
## [11] "Vendor" "Vendor.Number"
## [13] "Zip" "Contract.Number"
## [15] "PO.Number" "PO.Line"
## [17] "Invoice.Number" "Invoice.Line"
## [19] "Invoice.Distribution.Line" "Amount"
## [21] "Invoice.Date" "Payment.Method"
## [23] "Payment.Date" "Payment.Number"
## [25] "Payment.Status"
sqldf('select * from county_spending limit 5')
## Fiscal.Year.Period Fiscal.Year Service
## 1 6 2014 General Government
## 2 11 2014 General Government
## 3 8 2015 General Government
## 4 12 2014 General Government
## 5 6 2016 Public Safety
## Department Program
## 1 Human Resources Health & Employee Welfare
## 2 Human Resources Health & Employee Welfare
## 3 Liquor Control Warehouse Operations
## 4 Human Resources Health & Employee Welfare
## 5 Fire and Rescue Service Fiscal Management
## Fund Category
## 1 Employee Health Self Insurance Operating Expenses
## 2 Employee Health Self Insurance Operating Expenses
## 3 Liquor Not Defined
## 4 Employee Health Self Insurance Operating Expenses
## 5 Fire Operating Expenses
## Expense.Category Account.Code
## 1 Insurance (Non-Fringe Benefits) 65624
## 2 Insurance (Non-Fringe Benefits) 65628
## 3 Liquor Purchases (DLC) 66010
## 4 Training and Education 64100
## 5 Office Supplies/Equipment-Not Capitalized 62016
## Invoice.Description
## 1 Actives - Claims
## 2 Outside Agencies - Claims
## 3 Beer Purchases Of Inventory
## 4 Local Conference Related
## 5 Computer Supplies
## Vendor Vendor.Number Zip
## 1 GROUP HOSPITALIZATION AND MEDICAL SERVICES INC 10759 21117
## 2 UNITED HEALTHCARE SERVICES INC 54288 06103
## 3 BOSTON BEER CORPORATION 5645 02210
## 4 ALLIANCE FOR WORKPLACE EXCELLENCE 40341 20884
## 5 BENJAMIN OFFICE SUPPLY & SERVICES INC 34954 20850
## Contract.Number PO.Number PO.Line Invoice.Number Invoice.Line
## 1 1037952 1 121613PG52 1
## 2 1042182 3 2014-05-19 3
## 3 NA 90722428-429 1
## 4 NA 7 2
## 5 1044221 1 WO-11084858-1 1
## Invoice.Distribution.Line Amount Invoice.Date Payment.Method
## 1 1 1576281.42 12/16/2013 EFT
## 2 1 25615.94 05/19/2014 EFT
## 3 1 27394.34 02/11/2015 EFT
## 4 1 195.00 06/13/2014 CHECK
## 5 1 148.50 12/08/2015 MCG_JPM_SUA
## Payment.Date Payment.Number Payment.Status
## 1 12/20/2013 368883 RECONCILED
## 2 05/22/2014 380202 RECONCILED
## 3 02/19/2015 403394 RECONCILED
## 4 06/17/2014 2053265 RECONCILED
## 5 01/07/2016 6009472 NEGOTIABLE
county_spending_clean <-
sqldf('select Service,
`Fiscal.Year`,
Department,
Program,
Fund,
`Expense.Category`,
Amount,
`Payment.Date`,
`Payment.Method`
from county_spending')
sqldf('select count(`Fiscal.Year`) from county_spending_clean limit 5')
## count(`Fiscal.Year`)
## 1 837606
sqldf('select max(Amount) from county_spending_clean')
## max(Amount)
## 1 2.61e+08
sqldf('select avg(Amount) from county_spending_clean')
## avg(Amount)
## 1 14809.87
sqldf('select * from county_spending_clean
where Amount = (select max(Amount) from
county_spending_clean)')
## Service Fiscal.Year Department Program Fund
## 1 Debt Service 2015 Debt Service Debt Service Debt Service
## Expense.Category Amount Payment.Date Payment.Method
## 1 Not Defined 2.61e+08 12/05/2014 WIRE
sqldf('select `Fiscal.Year`, sum(Amount) from county_spending_clean
group by `Fiscal.Year`')
## Fiscal.Year sum(Amount)
## 1 2014 3679417152
## 2 2015 3891154142
## 3 2016 3842680800
## 4 2017 991584855
sqldf('select `Payment.Method`, count(*) as count_pm
from county_spending_clean
group by `Payment.Method`')
## Payment.Method count_pm
## 1 CHECK 405083
## 2 EFT 392772
## 3 MCG_JPM_SUA 38327
## 4 WIRE 1424
sqldf('select Fund, count(*) as count_fund
from county_spending_clean
group by Fund
order by count_fund desc')
## Fund count_fund
## 1 General Fund 369707
## 2 Liquor 113009
## 3 Montgomery Housing Initiative 80218
## 4 Fire 71956
## 5 Grant Fund 60559
## 6 Capital Fund 29644
## 7 Recreation 23295
## 8 Motor Pool 15226
## 9 Mass Transit 10437
## 10 Solid Waste Disposal 6136
## 11 Water Quality Protection 5857
## 12 Permitting 4891
## 13 Silver Spring Parking 4784
## 14 Bethesda Parking 4748
## 15 Central Duplicating 4176
## 16 Employee Health Self Insurance 3797
## 17 Cable TV 3523
## 18 Restricted Donations 3520
## 19 Non-Appropriated Funds 2890
## 20 Wheaton Parking 2750
## 21 Retirement Fund (ERS) 2534
## 22 Risk Management 2344
## 23 Community Use of Public Facilities 2248
## 24 Debt Service 1795
## 25 Montgomery Hills Parking 1613
## 26 Wheaton Urban District 1434
## 27 Silver Spring Urban District 1401
## 28 Retiree Health Benefits Trust Fund 1033
## 29 Solid Waste Collection 611
## 30 Employees Retirement Savings Plan (RSP) 554
## 31 Economic Development Fund 319
## 32 Bethesda Urban District 307
## 33 Leaf Vacuuming 290
sqldf('select Program, count(*) as count_prog
from county_spending_clean
group by Program
order by count_prog desc')
## Program
## 1 Warehouse Operations
## 2 Multi-Family Housing Programs
## 3 Management Services
## 4 Utilities
## 5 Facilities Management
## 6 Administration
## 7 Operations
## 8 Child Care Subsidies
## 9 Volunteer Services
## 10 Support Services
## 11 Rental & Energy Assistance Program
## 12 Detention Services
## 13 Collection Management
## 14 Administration, Outreach, and Support Services
## 15 Assessment & Continuing Case Mgmt Svcs
## 16 Office of the Chief Information Officer
## 17 Investigative Services
## 18 Child Welfare Services
## 19 Engineering and Capital Management
## 20 Community Support Network for People with Disabilities
## 21 Assisted Living Services
## 22 Office of Eligibility and Support Services
## 23 Office of the Chief Operating Officer
## 24 Building Design and Construction
## 25 Watershed Management Operations
## 26 Retail Sales Operations
## 27 Recreation Regions and Community Centers
## 28 Administrative Services
## 29 Office of the Director
## 30 STD/HIV Prevention & Treatment Program
## 31 School Health Services
## 32 Medicaid and Senior Programs
## 33 Montgomery County Employee Retirement Plans
## 34 Treatment Services - Admin
## 35 Operations and Administration
## 36 Office of Community Affairs
## 37 Community Grants
## 38 Central Duplicating, Imaging, Archiving, & Mail Svcs
## 39 Parking Operations
## 40 Snow Removal/Wind/Rain Storms
## 41 Home Care Services
## 42 Security of County Facilities
## 43 Health & Employee Welfare
## 44 Pre-Release and Reentry Services
## 45 Leases
## 46 Fiscal Management
## 47 Transit Equipment Services
## 48 Health Care for the Uninsured
## 49 Restricted Donations
## 50 Aquatics
## 51 Office of the Fire Chief
## 52 Youth Development
## 53 Ride On
## 54 Infants & Toddlers
## 55 Countywide Programs
## 56 Roadway and Related Maintenance
## 57 Transportation Design
## 58 Field Services
## 59 Fixed Costs
## 60 Councilmember Offices
## 61 Trauma Services
## 62 Marketing and Business Development
## 63 Human Resources Division
## 64 Behavioral Health Planning & Management
## 65 Watershed Management Capital Projects
## 66 Dental Services
## 67 Patrol Services
## 68 Positive Youth Development
## 69 Grants
## 70 CAO - Supervision & Management of Executive Branch Departments
## 71 Animal Services
## 72 Commuter Services
## 73 Community Partnership
## 74 Early Childhood Services
## 75 Transit Parking Facility Maintenance
## 76 Emergency Management Planning, Response & Recovery
## 77 Community Access to Public Space
## 78 Financial Management
## 79 Regional Services Centers
## 80 Heavy Equipment and Automotive Services
## 81 Prosecution Management
## 82 Traffic Signals & Advanced Transportation Mgmt System
## 83 Senior Nutrition Program
## 84 Director's Office
## 85 Debt Service
## 86 Labor and Employee Relations
## 87 Insurance
## 88 Library Services to the Public
## 89 Home & Community Based MA Waiver Services
## 90 Senior Adult Programs
## 91 Child & Adolescent School & Community Based Services
## 92 Grants Administration - Federal Programs
## 93 Intergovernmental Relations
## 94 Workforce Services
## 95 Enterprise Telecommunications and Services
## 96 Shelter Services
## 97 Business Operations and Performance
## 98 Telecommunications
## 99 Enterprise Systems and Operations
## 100 Residential Collection
## 101 Tree Maintenance
## 102 24-Hours Crisis Center
## 103 Community Health Services
## 104 Senior Community Services
## 105 Linkages To Learning
## 106 Commercial Building Construction
## 107 Ombudsman Services
## 108 Finance and Administration
## 109 MC311 Customer Service Center
## 110 Outpatient Behavioral Health Services - Child
## 111 Council Staff Operations
## 112 Cable Franchise Administration
## 113 Transportation Construction
## 114 Transportation Engineering and Management Services
## 115 Administration and Support
## 116 Promotion of Community and Business Activities
## 117 Streetscape Maintenance
## 118 County Executive - Policy Planning and Development
## 119 Outpatient Behavioral Health Services - Adult
## 120 Election Operations
## 121 Circuit Court Prosecution
## 122 Business Empowerment
## 123 Traffic Management and Operations
## 124 Administration/Policy Management
## 125 Traffic and Pedestrian Safety
## 126 Access To Behavioral Health Services
## 127 Office of the Chief
## 128 Housing Stabilization Services
## 129 Traffic Sign and Marking
## 130 Pre-Trial Services
## 131 Customer Service
## 132 Information Management
## 133 Environmental Policy and Compliance
## 134 Management Services Division
## 135 Parking Outside the Parking Districts
## 136 Gilchrist Center
## 137 Municipal Support
## 138 Boards, Committees and Commissions
## 139 Law Library
## 140 Transfer Station
## 141 Agricultural Services
## 142 Information Technology
## 143 Budget Preparation and Administration
## 144 Planned Lifecycle Asset Replacement
## 145 Oaks Landfill
## 146 County Cable Montgomery
## 147 Transportation Planning
## 148 Enterprise Applications and Solutions
## 149 Property Acquisition
## 150 Licensure, Regulation and Education
## 151 Accounting and Inventory Systems
## 152 Chief Public Health
## 153 Courtroom/Courthouse Security and Transport
## 154 Compensation and Employee Benefit Adjustments
## 155 Office of the Chief Operating Officer (COO)
## 156 FiberNet
## 157 Communicable Disease & Epidemiology
## 158 Streetlighting
## 159 Procurement
## 160 Enterprise Resource Planning Division (ERPD)
## 161 Tuberculosis Program
## 162 Desktop Computer Modernization
## 163 Cancer & Tobacco Prevention
## 164 Automation
## 165 University of Maryland-Extension (UMD-Extention)
## 166 Land Development
## 167 Public Relations
## 168 Public Education Government Access (PEG) Operations
## 169 Environmental Health Regulatory Services
## 170 Countywide Generic
## 171 Bike Share
## 172 Forensic Services - Adult
## 173 Commercial Recycling
## 174 Jury
## 175 Permanent Supportive Housing
## 176 Resource Recovery Facility & Related Waste Transfer
## 177 Dickerson Compost Facility
## 178 Special Projects
## 179 Household & Small Quantity Hazardous Waste Management
## 180 Gude Landfill
## 181 Consumer Protection
## 182 Licensing and Registration
## 183 Specialty Behavioral Health Services
## 184 Residential Building Construction & Intake
## 185 Vacuum Leaf Collection
## 186 Chief Children, Youth & Families
## 187 Passenger Facilities
## 188 Victim/Witness Court Assistance
## 189 Health Care & Group Residential Services
## 190 Organizational Support Services
## 191 Recreation Outreach Services
## 192 Chief Aging & Disability Services
## 193 Legislative Branch Communications Outreach
## 194 Health and Human Services
## 195 Zoning and Administrative Hearings
## 196 Public Health Emergency Preparedness & Response Program
## 197 Commission for Women
## 198 Selection and Recruitment
## 199 District Court Prosecution
## 200 Housing Administration
## 201 Respite Care
## 202 Housing Code Enforcement
## 203 Support for Recycling Volunteers
## 204 Procurement Operations
## 205 Biotech Credit Supp
## 206 Domestic Violence
## 207 Enforcement
## 208 Transportation Community Outreach
## 209 Voter Registration Services
## 210 Recycling Center
## 211 Transit Operations Planning
## 212 Working Families Income Supplement
## 213 Enhanced Security
## 214 Insurance Defense Litigation
## 215 Zoning Related Hearings and Administrative Appeals
## 216 Criminal Process/Warrants and Extraditions
## 217 Recycling Outreach And Education
## 218 Transportation Policy
## 219 Business Relations and Compliance
## 220 Affordable Housing Programs
## 221 Merit System Oversight
## 222 Chief Behavioral Health & Crisis Services
## 223 Landlord-Tenant Mediation
## 224 Multi-Family Recycling
## 225 Retail Contracted Operations
## 226 Web Content and Graphic Management
## 227 Chief Special Needs Housing
## 228 Office of Business Relations and Compliance
## 229 Bridge Maintenance
## 230 Neighborhood Revitalization
## 231 Taxi Regulation
## 232 Human Resources and Appeals
## 233 Inspector General
## 234 Mental Health Services Seniors & Persons with Disabilities
## 235 Aging & Disability Resource Unit
## 236 Fire and Rescue Service
## 237 Community Mediation and Public Affairs
## 238 CIP
## 239 Finance and Procurement
## 240 Legislative Oversight
## 241 Occupational Safety and Health
## 242 Municipal Tax Duplication
## 243 Civil Process
## 244 Real Estate Program
## 245 Zoning and Site Plan Enforcement
## 246 Commission on Common Ownership Communities
## 247 Payroll
## 248 Traffic Planning
## 249 Public Interest Litigation
## 250 Out Of County Refuse Disposal
## 251 Resurfacing
## 252 Energy and Sustainabiilty
## 253 Ethics Program Compliance
## 254 Internal Audit
## 255 Sidewalk Repair
## 256 Rockville Parking District
## 257 Arts and Humanities Council
## 258 EEO Compliance and Diversity Management
## 259 Economic Development Grant and Loan Program
## 260 Grants To Municipalities in Lieu Of Shares Tax
## 261 Zoning, Land Use and Economic Development
## 262 Site 2
## 263 Procurement Services
## 264 Yard Trim Reduction
## 265 Community Access to Cable
## 266 Conference and Visitors Bureau
## 267 MOVE - Make Office Vacancies Extinct Program
## 268 Housing Opportunities Commission
## 269 Homeowners' Association Road Maintenance Reimb.
## 270 Waste System Planning
## 271 Montgomery Coalition for Adult English Literacy
## 272 Accounts Receivable
## 273 Dickerson Master Plan Implementation
## 274 Soil Conservation
## 275 Independent Audit
## 276 Juvenile Court Prosecution
## 277 Major Fraud and Special Investigations
## 278 Compliance
## 279 General Accounting
## 280 State Property Tax Services
## 281 Takoma Park Police Rebate
## 282 Goverment Operations
## 283 Interagency Technolicy, Policy, and Coordination Commission
## 284 Accounts Payable
## 285 Delivery Operations
## 286 Historical Activities
## 287 Metro Washington Council of Governments
## 288 Fair Housing
## 289 Consolidated Retiree Health Benefit Trust - MCPS
## 290 County Associations
## 291 Inauguration and Transition
## 292 Montgomery College
## 293 State Retirement Contribution
## 294 Takoma Park Library Annual Payments
## 295 Tax Operations
## 296 Conference Center
## 297 Small Business Revolving Loan Program
## 298 Bikeway Maintenance
## 299 Equity Investments
## 300 Maryland National Capital Park And Planning Commission
## 301 Public Technology, Inc.
## 302 Waste Reduction
## 303 Children?s Opportunity Fund
## 304 Training and Organizational Development
## 305 Common Ownership Community Program
## 306 Grants Accounting
## 307 CyberSecurity Credit
## 308 Fire Prevention and Code Compliance
## 309 Human Resources
## 310 MCEDC
## 311 MEDCO Grant - Incubator Network
## 312 Prisoner Medical Services
## 313 Satelite Sites
## 314 WorkSource Montgomery, Inc
## count_prog
## 1 104392
## 2 80495
## 3 39405
## 4 39404
## 5 30068
## 6 30020
## 7 29832
## 8 27700
## 9 22092
## 10 13673
## 11 13613
## 12 13600
## 13 13018
## 14 9191
## 15 8362
## 16 8091
## 17 7975
## 18 7738
## 19 7366
## 20 6438
## 21 6388
## 22 6096
## 23 6006
## 24 5958
## 25 5763
## 26 5683
## 27 5396
## 28 5302
## 29 5291
## 30 5105
## 31 4910
## 32 4540
## 33 4516
## 34 4339
## 35 4199
## 36 4193
## 37 4185
## 38 4171
## 39 4035
## 40 3991
## 41 3953
## 42 3917
## 43 3900
## 44 3810
## 45 3717
## 46 3703
## 47 3602
## 48 3567
## 49 3542
## 50 3514
## 51 3402
## 52 3345
## 53 3199
## 54 3154
## 55 3128
## 56 3045
## 57 3044
## 58 2931
## 59 2923
## 60 2870
## 61 2845
## 62 2708
## 63 2629
## 64 2621
## 65 2576
## 66 2534
## 67 2497
## 68 2489
## 69 2472
## 70 2459
## 71 2391
## 72 2390
## 73 2341
## 74 2341
## 75 2317
## 76 2291
## 77 2248
## 78 2184
## 79 2068
## 80 2064
## 81 1915
## 82 1898
## 83 1839
## 84 1830
## 85 1795
## 86 1738
## 87 1730
## 88 1662
## 89 1651
## 90 1624
## 91 1601
## 92 1582
## 93 1575
## 94 1540
## 95 1474
## 96 1473
## 97 1437
## 98 1426
## 99 1385
## 100 1383
## 101 1357
## 102 1346
## 103 1346
## 104 1331
## 105 1322
## 106 1300
## 107 1298
## 108 1269
## 109 1265
## 110 1258
## 111 1243
## 112 1201
## 113 1200
## 114 1190
## 115 1179
## 116 1163
## 117 1155
## 118 1151
## 119 1139
## 120 1109
## 121 1076
## 122 1041
## 123 988
## 124 964
## 125 927
## 126 921
## 127 916
## 128 911
## 129 900
## 130 889
## 131 871
## 132 839
## 133 753
## 134 750
## 135 744
## 136 741
## 137 725
## 138 720
## 139 719
## 140 699
## 141 675
## 142 653
## 143 646
## 144 634
## 145 630
## 146 619
## 147 615
## 148 607
## 149 594
## 150 587
## 151 581
## 152 567
## 153 556
## 154 549
## 155 530
## 156 524
## 157 517
## 158 497
## 159 475
## 160 471
## 161 471
## 162 459
## 163 453
## 164 452
## 165 450
## 166 418
## 167 418
## 168 415
## 169 405
## 170 403
## 171 384
## 172 374
## 173 340
## 174 339
## 175 338
## 176 331
## 177 327
## 178 320
## 179 319
## 180 318
## 181 311
## 182 309
## 183 307
## 184 305
## 185 292
## 186 289
## 187 285
## 188 281
## 189 280
## 190 280
## 191 278
## 192 273
## 193 271
## 194 267
## 195 262
## 196 250
## 197 246
## 198 241
## 199 237
## 200 237
## 201 235
## 202 232
## 203 231
## 204 227
## 205 223
## 206 223
## 207 223
## 208 222
## 209 217
## 210 206
## 211 201
## 212 198
## 213 197
## 214 197
## 215 195
## 216 188
## 217 185
## 218 185
## 219 180
## 220 175
## 221 174
## 222 173
## 223 169
## 224 159
## 225 158
## 226 150
## 227 143
## 228 141
## 229 134
## 230 128
## 231 128
## 232 127
## 233 127
## 234 126
## 235 119
## 236 119
## 237 109
## 238 105
## 239 100
## 240 97
## 241 95
## 242 94
## 243 93
## 244 92
## 245 92
## 246 82
## 247 82
## 248 79
## 249 78
## 250 70
## 251 66
## 252 64
## 253 60
## 254 60
## 255 60
## 256 59
## 257 58
## 258 57
## 259 49
## 260 48
## 261 43
## 262 42
## 263 40
## 264 40
## 265 39
## 266 39
## 267 37
## 268 36
## 269 34
## 270 32
## 271 29
## 272 28
## 273 28
## 274 28
## 275 25
## 276 24
## 277 23
## 278 21
## 279 21
## 280 20
## 281 18
## 282 17
## 283 17
## 284 14
## 285 14
## 286 11
## 287 11
## 288 10
## 289 7
## 290 7
## 291 7
## 292 7
## 293 6
## 294 6
## 295 6
## 296 5
## 297 5
## 298 4
## 299 4
## 300 4
## 301 4
## 302 4
## 303 3
## 304 3
## 305 2
## 306 2
## 307 1
## 308 1
## 309 1
## 310 1
## 311 1
## 312 1
## 313 1
## 314 1
sqldf('select `Expense.Category`, count(*) as count_ec
from county_spending_clean
group by `Expense.Category`
order by count_ec desc')
## Expense.Category count_ec
## 1 Contract and Services 233948
## 2 Liquor Purchases (DLC) 102068
## 3 Public Assistance 91724
## 4 Travel 75129
## 5 Utilities 53465
## 6 Office Supplies/Equipment-Not Capitalized 49556
## 7 Miscellaneous Operating Expenses 34335
## 8 Other Supplies/Materials/Equipment 31316
## 9 Fire Department Operating Expenses 21775
## 10 Phones/Telecommunication Services 20812
## 11 Books/Videos/Subscriptions 15675
## 12 Motor Vehicle Supplies/Equipment 14767
## 13 Training and Education 13241
## 14 Rental Leases 9876
## 15 Medical/Health Supplies 9841
## 16 Uniforms 8397
## 17 Public Safety Supplies/Equipment 7792
## 18 Recreation Supplies/Equipment 6643
## 19 Maintenance 4983
## 20 Special County Functions 4311
## 21 Insurance (Non-Fringe Benefits) 3283
## 22 Memberships and Dues 2947
## 23 Advertising 2357
## 24 Outside Postage and Mailing Services 2223
## 25 Property/Donation Disbursements 2080
## 26 Boards/Committees/Commissions 1808
## 27 Autos and Other Vehicles (Over $10,000) 1611
## 28 Outside Printing 1478
## 29 Mail - Central Duplicating Services 1388
## 30 Motor Pool 1269
## 31 Charges from Others 1112
## 32 Debt Service - Interest Payment 1056
## 33 Transfer to MCPS 639
## 34 Printing - Cental Duplicating Services 593
## 35 Land 483
## 36 Furniture 444
## 37 Drug Enforcement Fund Disbursements 399
## 38 Loans 371
## 39 Intergovernmental Operating Expenditures 367
## 40 Furniture and Fixtures (Over $10,000) 287
## 41 Debt Service - Principal Payment 272
## 42 Equipment and Machinery (Over $10,000) 259
## 43 Refunds 216
## 44 Debt Service - Issue Costs Paid (Operating) 214
## 45 Automation Equipment (Over $10,000) 195
## 46 Debt Svc Fees - Acct Use 133
## 47 Site Improvements 110
## 48 Buildings 76
## 49 Miscellaneous Capital Expenses (Over $10,000) 73
## 50 Charges to Others 66
## 51 Transfer to HOC 37
## 52 Homeowners Warranty Payments 34
## 53 Debt Svc Issue Costs CAP (Operating) - Acct Use 24
## 54 Indirect Costs 21
## 55 Not Defined 15
## 56 Transfer to Montgomery College 7
## 57 Transfer to M-NCPPC 4
## 58 Transfer to General Fund 1
sqldf('select `Fiscal.Year`, Department, sum(Amount)
from county_spending_clean
group by `Fiscal.Year`,Department
having `Fiscal.Year` = "2016"')
## Fiscal.Year Department
## 1 2016 Board of Appeals
## 2 2016 Board of Elections
## 3 2016 CIP
## 4 2016 Circuit Court
## 5 2016 Community Engagement Cluster
## 6 2016 Community Use of Public Facilities
## 7 2016 Consumer Protection
## 8 2016 Correction and Rehabilitation
## 9 2016 County Attorney
## 10 2016 County Council
## 11 2016 County Executive
## 12 2016 Countywide Generic
## 13 2016 Debt Service
## 14 2016 Emergency Management and Homeland Security
## 15 2016 Environmental Protection
## 16 2016 Ethics Commission
## 17 2016 Finance
## 18 2016 Fire and Rescue Service
## 19 2016 General Services
## 20 2016 Health and Human Services
## 21 2016 Housing Opportunities Commission
## 22 2016 Housing and Community Affairs
## 23 2016 Human Resources
## 24 2016 Human Rights
## 25 2016 Inspector General
## 26 2016 Intergovernmental Relations
## 27 2016 Legislative Oversight
## 28 2016 Liquor Control
## 29 2016 Management and Budget
## 30 2016 Maryland National Capital Park And Planning Commission
## 31 2016 Merit System Protection Board
## 32 2016 Montgomery College
## 33 2016 Non-Departmental Accounts
## 34 2016 Not Defined
## 35 2016 Office of Agriculture
## 36 2016 Office of Procurement
## 37 2016 Permitting Services
## 38 2016 Police
## 39 2016 Public Information
## 40 2016 Public Libraries
## 41 2016 Recreation
## 42 2016 Restricted Donations
## 43 2016 Sheriff
## 44 2016 State's Attorney
## 45 2016 Technology Services
## 46 2016 Transportation
## 47 2016 Zoning and Administrative Hearings
## sum(Amount)
## 1 1.784596e+04
## 2 2.405082e+06
## 3 2.268234e+07
## 4 2.809719e+06
## 5 4.401194e+06
## 6 7.003788e+06
## 7 1.640467e+04
## 8 6.860687e+06
## 9 5.730573e+05
## 10 3.796568e+05
## 11 4.818420e+05
## 12 1.479154e+09
## 13 6.494358e+08
## 14 4.570757e+06
## 15 1.114085e+08
## 16 7.560790e+04
## 17 5.787871e+07
## 18 3.360166e+07
## 19 2.252346e+08
## 20 1.262777e+08
## 21 6.050750e+06
## 22 4.360503e+07
## 23 2.247381e+08
## 24 7.317163e+04
## 25 1.275684e+04
## 26 1.085905e+05
## 27 3.127456e+04
## 28 2.267986e+08
## 29 4.551852e+04
## 30 8.115000e+05
## 31 8.727230e+03
## 32 1.283200e+08
## 33 1.557078e+08
## 34 2.735090e+07
## 35 8.204878e+05
## 36 2.595744e+05
## 37 5.599682e+06
## 38 2.866406e+07
## 39 7.500009e+05
## 40 9.086644e+06
## 41 1.040594e+07
## 42 5.477115e+05
## 43 1.721015e+06
## 44 6.687725e+05
## 45 4.643626e+07
## 46 1.887365e+08
## 47 5.233464e+04
county_spending_clean %>%
filter(`Fiscal.Year`=="2016") %>%
select(Department, Amount) %>%
group_by(Department) %>%
summarize(Amount=sum(Amount,na.rm=TRUE)) %>%
arrange(desc(Amount)) %>%
top_n(10) %>%
ggplot(mapping = aes(x=Department,y=Amount))+
geom_bar(stat = "identity",fill="yellow",col="cyan") +
scale_y_continuous(labels = unit_format("k",1e-6))+
theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.5))
## Selecting by Amount
county_spending_clean %>%
filter(Department %in% c("Countywide Generic",
"Debt Service",
"Environmental Protection",
"General Services",
"Human Resources"))%>%
select(`Fiscal.Year`, Amount, Department) %>%
group_by(Department,`Fiscal.Year`)%>%
summarize(Amount=sum(Amount,na.rm=TRUE)) %>%
arrange(`Fiscal.Year`)%>%
ggplot(mapping = aes(x=`Fiscal.Year`,y=Amount, group = Department, colour = Department))+
geom_line(stat = "identity") +
scale_y_continuous(labels = unit_format("k",1e-6))+
theme(axis.text.x=element_text(angle=90,hjust=1,vjust=0.5))
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.