NA should represent the public, but currently includes some business entities such as sole proprietorships, hospitals, banks, and such. It requires further refining in the code.
data_merged_new <- data_merged %>%
unite(natureOfsuit, NOS, nature_of_suit, sep = ' ')
data_merged_new$natureOfsuit <- as.factor(data_merged_new$natureOfsuit)
levels(data_merged_new$natureOfsuit)
## [1] "110 INSURANCE"
## [2] "120 MARINE CONTRACT ACTIONS"
## [3] "130 MILLER ACT"
## [4] "140 NEGOTIABLE INSTRUMENTS"
## [5] "150 OVERPAYMENTS & ENFORCEMENT OF JUDGMENTS"
## [6] "152 RECOVERY OF DEFAULTED STUDENT LOANS"
## [7] "160 STOCKHOLDER'S SUITS"
## [8] "190 OTHER CONTRACT ACTIONS"
## [9] "195 CONTRACT PRODUCT LIABILITY"
## [10] "210 LAND CONDEMNATION"
## [11] "220 FORECLOSURE"
## [12] "230 RENT, LEASE, EJECTMENT"
## [13] "240 TORTS TO LAND"
## [14] "245 TORT PRODUCT LIABILITY"
## [15] "290 OTHER REAL PROPERTY ACTIONS"
## [16] "310 AIRPLANE PERSONAL INJURY"
## [17] "315 AIRPLANE PRODUCT LIABILITY"
## [18] "320 ASSAULT, LIBEL, AND SLANDER"
## [19] "340 MARINE PERSONAL INJURY"
## [20] "345 MARINE - PRODUCT LIABILITY"
## [21] "350 MOTOR VEHICLE PERSONAL INJURY"
## [22] "355 MOTOR VEHICLE PRODUCT LIABILITY"
## [23] "360 OTHER PERSONAL INJURY"
## [24] "362 MEDICAL MALPRACTICE"
## [25] "365 PERSONAL INJURY -PRODUCT LIABILITY"
## [26] "368 ASBESTOS PERSONAL INJURY - PROD.LIAB."
## [27] "370 OTHER FRAUD"
## [28] "371 TRUTH IN LENDING"
## [29] "380 OTHER PERSONAL PROPERTY DAMAGE"
## [30] "385 PROPERTY DAMAGE -PRODUCT LIABILTY"
## [31] "410 ANTITRUST"
## [32] "422 BANKRUPTCY APPEALS RULE 28 USC 158"
## [33] "423 BANKRUPTCY WITHDRAWAL 28 USC 157"
## [34] "430 BANKS AND BANKING"
## [35] "440 OTHER CIVIL RIGHTS"
## [36] "441 CIVIL RIGHTS VOTING"
## [37] "442 CIVIL RIGHTS JOBS"
## [38] "443 CIVIL RIGHTS ACCOMMODATIONS"
## [39] "445 CIVIL RIGHTS ADA EMPLOYMENT"
## [40] "446 CIVIL RIGHTS ADA OTHER"
## [41] "450 INTERSTATE COMMERCE"
## [42] "462 NATURALIZATION, PETITION FOR HEARING OF DENIAL"
## [43] "463 HABEAS CORPUS – ALIEN DETAINEE"
## [44] "470 CIVIL (RICO)"
## [45] "480 CONSUMER CREDIT"
## [46] "490 CABLE/SATELLITE TV"
## [47] "510 PRISONER PETITIONS -VACATE SENTENCE"
## [48] "530 PRISONER PETITIONS -HABEAS CORPUS"
## [49] "540 PRISONER PETITIONS -MANDAMUS AND OTHER"
## [50] "550 PRISONER -CIVIL RIGHTS"
## [51] "555 PRISONER - PRISON CONDITION"
## [52] "610 AGRICULTURAL ACTS"
## [53] "620 FOOD AND DRUG ACTS"
## [54] "625 DRUG RELATED SEIZURE OF PROPERTY"
## [55] "660 OCCUPATIONAL SAFETY/HEALTH"
## [56] "690 OTHER FORFEITURE AND PENALTY SUITS"
## [57] "710 FAIR LABOR STANDARDS ACT"
## [58] "720 LABOR/MANAGEMENT RELATIONS ACT"
## [59] "730 LABOR/MANAGEMENT REPORT & DISCLOSURE"
## [60] "740 RAILWAY LABOR ACT"
## [61] "790 OTHER LABOR LITIGATION"
## [62] "791 EMPLOYEE RETIREMENT INCOME SECURITY ACT"
## [63] "810 SELECTIVE SERVICE"
## [64] "820 COPYRIGHT"
## [65] "830 PATENT"
## [66] "840 TRADEMARK"
## [67] "850 SECURITIES, COMMODITIES, EXCHANGE"
## [68] "863 D.I.W.C./D.I.W.W."
## [69] "864 S.S.I.D."
## [70] "865 R.S.I."
## [71] "870 TAX SUITS"
## [72] "875 CUSTOMER CHALLENGE 12 USC 3410"
## [73] "890 OTHER STATUTORY ACTIONS"
## [74] "891 AGRICULTURAL ACTS"
## [75] "893 ENVIRONMENTAL MATTERS"
## [76] "895 FREEDOM OF INFORMATION ACT OF 1974"
## [77] "950 CONSTITUTIONALITY OF STATE STATUTES"
levels(data_merged$cause)
## [1] ""
## [2] "35:145 Patent Infringement"
## [3] "28:1332 Diversity-Insurance Contract"
## [4] "28:1441 Petition for Removal - Employment Discrim"
## [5] "42:2000 Job Discrimination (ADA 1990)"
## [6] "28:1332 Diversity-Other Contract"
## [7] "17:501 Copyright Infringement"
## [8] "28:1331 Federal Question: Other Civil Rights"
## [9] "42:1983 Civil Rights (Employment Discrimination)"
## [10] "42:1983 Civil Rights Act"
## [11] "28:1338 Trademark Infringement"
## [12] "28:0158 Notice of Appeal re Bankruptcy Matter (BA"
## [13] "21:881 Forfeiture Property-Drugs"
## [14] "15:0045 Federal Trade Commission Act"
## [15] "15:1051 Trademark Infringement"
## [16] "28:2241 Petition for Writ of Habeas Corpus (federal)"
## [17] "28:1332 Diversity-Personal Injury"
## [18] "28:1441 Petition for Removal- Personal Injury"
## [19] "09:1 U.S. Arbitration Act"
## [20] "31:3729 False Claims Act"
## [21] "15:1692 Fair Debt Collection Act"
## [22] "28:1332 Diversity-Breach of Contract"
## [23] "28:1332 Diversity-Medical Malpractice"
## [24] "15:1125 Trademark Infringement (Lanham Act)"
## [25] "28:1331 Fed. Question: Personal Injury"
## [26] "28:1331 Fed. Question: Employment Discrimination"
## [27] "28:0157 Motion for Withdrawal of Reference"
## [28] "18:1961 Racketeering (RICO) Act"
## [29] "15:78m(a) Securities Exchange Act"
## [30] "28:451 Employment Discrimination"
## [31] "42:405 Review of HHS Decision (DIWC)"
## [32] "42:12101 Americans With Disabilities Act"
## [33] "28:1441 Petition for Removal"
## [34] "29:626 Job Discrimination (Age)"
## [35] "28:1332 Diversity - Legal Malpractice"
## [36] "No cause code entered"
## [37] "28:1332 Diversity-Tort/Motor Vehicle (P.I.)"
## [38] "28:1332 Diversity-Breach of Fiduciary Duty"
## [39] "28:1332 Diversity-Contract Dispute"
## [40] "26:7403 Suit to Enforce Federal Tax Lien"
## [41] "28:1332 Diversity-Contract Default"
## [42] "28:1343 Violation of Civil Rights"
## [43] "28:1332 Diversity-Product Liability"
## [44] "15:1681 Fair Credit Reporting Act"
## [45] "28:1441 Petition for Removal- Labor/Mgmnt. Relatio"
## [46] "28:1441 Petition For Removal--Other Contract"
## [47] "28:1332 Diversity-Fraud"
## [48] "28:1444 Petition for Removal- Foreclosure"
## [49] "28:1338 Patent Infringement"
## [50] "28:1441 Petition for Removal- Petition to Quiet Title"
## [51] "28:1441 Petition for Removal- Breach of Contract"
## [52] "35:271 Patent Infringement"
## [53] "42:2000 Job Discrimination (Sex)"
## [54] "28:1983 Civil Rights"
## [55] "28:2201 Declaratory Judgment"
## [56] "28:1332 Diversity-Property Damage"
## [57] "28:1441 Petition for Removal- Property Damage"
## [58] "28:1441 Notice of Removal"
## [59] "28:1441 Petition for Removal- Insurance Contract"
## [60] "05:702 Administrative Procedure Act"
## [61] "28:1331 Fed. Question: Fair Labor Standards"
## [62] "28:1391 Personal Injury"
## [63] "28:1331 Fed. Question"
## [64] "28:1332 Diversity-(Citizenship)"
## [65] "28:1441 Petition for Removal- Civil Rights Act"
## [66] "17:101 Copyright Infringement"
## [67] "28:1441 Petition for Removal- Torts to Land"
## [68] "28:1441 Petition for Removal- Product Liability"
## [69] "29:623 Job Discrimination (Age)"
## [70] "28:1345 Default of Student Loan"
## [71] "29:0794 Job Discrimination (Handicap)"
## [72] "28:1651 Petition for Writ of Mandamus"
## [73] "28:2201 Constitutionality of State Statute(s)"
## [74] "21:841 Forfeiture Property-Drugs"
## [75] "45:151 Railway Labor Act"
## [76] "28:1331 Fed. Question: Breach of Contract"
## [77] "28:1332 Diversity-Airline Crash"
## [78] "07:608(a) Agriculture Marketing Agreement Act"
## [79] "7:6(b) Federal Commodity Exchange Regulation"
## [80] "07:499 Agricultural Commodities Act"
## [81] "28:2201 Declaratory Judgment (Insurance)"
## [82] "28:1338 Copyright Infringement"
## [83] "28:1331 Fed. Question: Trademark"
## [84] "29:160(1) National Labor Relations Act"
## [85] "42:1981 Job Discrimination (Race)"
## [86] "28:1332 Diversity-Declaratory Judgment"
## [87] "42:1981 Civil Rights"
## [88] "28:1441 - Petition for Removal: SEC Act"
## [89] "28:1346 Tort Claim"
## [90] "29:1451 E.R.I.S.A."
## [91] "21:881 Forfeiture Property - Real Estate"
## [92] "29:1002 E.R.I.S.A.: Employee Retirement"
## [93] "28:1441 Petition for Removal- Tort/Motor Vehicle"
## [94] "28:1331 Fed. Question: Securities Violation"
## [95] "42:2000 Job Discrimination (Age)"
## [96] "28:2674 Federal Tort Claims Act"
## [97] "09:0010 Petition to Vacate Arbitration Award"
## [98] "Motion to Compel"
## [99] "42:1383 Review of HHS Decision"
## [100] "42:405 Review of HHS Decision (DIWW)"
## [101] "28:1361 Petition for Writ of Mandamus"
## [102] "42:2000 Job Discrimination (Race)"
## [103] "28:1441 Petition for Removal- Injunctive/Declarato"
## [104] "47:553 Unauthorized Reception of Cable Service"
## [105] "42:2601 Family and Medical Leave Act of 1993"
## [106] "28:1332 Diversity-Employment Discrimination"
## [107] "28:1331(a) Fed. Question: Real Property"
## [108] "29:651 Occupational Safety/Health"
## [109] "28:1441 Petition for Removal Libel,Assault,Slander"
## [110] "28:1332 Diversity-Injunctive & Declaratory Relief"
## [111] "28:1345 Recovery of Debt to US"
## [112] "28:1651 Petition for Writ of Coram Nobis"
## [113] "42:4321 Review of Agency Action-Environment"
## [114] "42:2000e Job Discrimination (Employment)"
## [115] "29:151 Labor: Review of Agency Action"
## [116] "28:1331 Fed. Question: Medical Malpractice"
## [117] "Contempt Proceedings"
## [118] "28:1332 Diversity-Torts to Land"
## [119] "28:1441 Petition for Removal- Negotiable Instrumen"
## [120] "28:1001 E.R.I.S.A."
## [121] "28:2671 Federal Tort Claims Act"
## [122] "28:1441 Petition for Removal- Contract Dispute"
## [123] "15:1121 Trademark Infringement"
## [124] "29:206 Collect Unpaid Wages"
## [125] "28:1332 Diversity-Negotiable Instrument"
## [126] "28:1441 Petition for Removal- Medical Malpractice"
## [127] "28:1442 Petition for Removal"
## [128] "28:2675 Federal Tort Claims Act"
## [129] "16:0823 Federal Power Act"
## [130] "28:1332 Diversity-Notice of Removal"
## [131] "28:1331 Fed Question: Fed Communications Act of 1"
## [132] "15:1601 Truth in Lending"
## [133] "28:1446 Petition for Removal- Personal Injury"
## [134] "28:1443(1) Rent, Lease & Ejectment"
## [135] "28:1442 Petition for Removal- Breach of Contract"
## [136] "28:1335 Interpleader Action"
## [137] "29:201 Fair Labor Standards Act"
## [138] "Motion to Quash"
## [139] "20:1071 Higher Education Act 1965"
## [140] "28:1337 Sherman-Clayton Act"
## [141] "15:1640 Truth in Lending"
## [142] "28:1332 Diversity-Interpleader Action"
## [143] "28:1332 Diversity-Libel,Assault,Slander"
## [144] "28:1332 Diversity-Account Receivable"
## [145] "28:1332 Diversity-Auto Negligence"
## [146] "28:1446 Notice of Removal"
## [147] "28:1331 Fed. Question: Interstate Commerce Act"
## [148] "28:1442 Notice of Removal"
## [149] "29:201 Denial of Overtime Compensation"
## [150] "28:1331 Fed. Question: Review Agency Decision"
## [151] "8:1105(a) Aliens: Habeas Corpus to Release INS Det"
## [152] "28:1346 Breach of Contract"
## [153] "42:416 Denial of Social Security Benefits"
## [154] "23:1441 Contract Real Estate"
## [155] "12:635 Breach of Insurance Contract"
## [156] "28:1441 Petition for Removal- Declaratory Judgment"
## [157] "05:551 Administrative Procedure Act"
## [158] "28:1332 Diversity-Tort/Non-Motor Vehicle"
## [159] "28:1441 Petition for Removal- Asbestos Litigation"
## [160] "29:1109 Breach of Fiduciary Duties"
## [161] "31:3545 Action to Recovery Money"
## [162] "35:183 Patent Infringement"
library(ggplot2)
data_merged %>%
count(nature_of_suit) %>%
top_n(10, n) %>%
ggplot(aes(x = reorder(nature_of_suit, desc(n)), y = n, fill = "Orange")) +
geom_col(show.legend = FALSE)+
theme(axis.text.x = element_text(angle = 45)) +
labs(title = "Top 10 Nature of Suits",
x = NULL,
y = "count")