Home

The following data “State/UT-wise Under trial Prisoners by Type of Offences under Indian Penal Code (IPC) as on 31st December, 2020” has been taken from data.gov.in. In the following sections we will see EDA through which inferences are taken and some visualization of this data set.

DD

Summary

Dimension
[1] 36 29
Summary
 Sl..No...Col..1. State.UT..Col..2.      S.U           
 Min.   : 1.00    Length:36          Length:36         
 1st Qu.: 9.75    Class :character   Class :character  
 Median :18.50    Mode  :character   Mode  :character  
 Mean   :18.50                                         
 3rd Qu.:27.25                                         
 Max.   :36.00                                         
 Offences.affecting.the.Human.Body...Murder....Col..3.
 Min.   :    0.0                                      
 1st Qu.:   73.5                                      
 Median :  588.0                                      
 Mean   : 2022.4                                      
 3rd Qu.: 3308.0                                      
 Max.   :12669.0                                      
 Offences.affecting.the.Human.Body...C.H..not.amounting.to.Murder....Col..4.
 Min.   :   0.00                                                            
 1st Qu.:   2.75                                                            
 Median :  70.50                                                            
 Mean   : 240.31                                                            
 3rd Qu.: 226.00                                                            
 Max.   :3510.00                                                            
 Offences.affecting.the.Human.Body...Dowry.Deaths....Col..5.
 Min.   :   0.0                                             
 1st Qu.:   0.0                                             
 Median :  42.5                                             
 Mean   : 401.8                                             
 3rd Qu.: 189.8                                             
 Max.   :8584.0                                             
 Offences.affecting.the.Human.Body...Attempt.to.Murder....Col..6.
 Min.   :   0.0                                                  
 1st Qu.:  19.0                                                  
 Median : 266.0                                                  
 Mean   : 814.6                                                  
 3rd Qu.:1127.0                                                  
 Max.   :5857.0                                                  
 Offences.affecting.the.Human.Body...Kidnapping...Abduction....Col..7.
 Min.   :   0.0                                                       
 1st Qu.:   7.5                                                       
 Median : 124.0                                                       
 Mean   : 428.8                                                       
 3rd Qu.: 522.0                                                       
 Max.   :4067.0                                                       
 Offences.affecting.the.Human.Body...Rape....Col..8.
 Min.   :   0.00                                    
 1st Qu.:  57.75                                    
 Median : 377.50                                    
 Mean   :1126.25                                    
 3rd Qu.:1576.75                                    
 Max.   :9030.00                                    
 Offences.affecting.the.Human.Body...Assault.on.Women.with.Intent.to.Outrage.her.Modesty....Col..9.
 Min.   :   0.00                                                                                   
 1st Qu.:   2.75                                                                                   
 Median :  39.00                                                                                   
 Mean   : 135.69                                                                                   
 3rd Qu.: 146.75                                                                                   
 Max.   :1402.00                                                                                   
 Total.Offences.affecting.the.Human.Body....Col..10.
 Min.   :    0.0                                    
 1st Qu.:  178.2                                    
 Median : 1679.5                                    
 Mean   : 5169.8                                    
 3rd Qu.: 7758.8                                    
 Max.   :45119.0                                    
 Offences.against.Public.Tranquility...Riots....Col..11.
 Min.   :  0.00                                         
 1st Qu.:  0.00                                         
 Median : 13.00                                         
 Mean   : 61.58                                         
 3rd Qu.: 83.25                                         
 Max.   :525.00                                         
 Offences.against.Property...Thefts....Col..12.
 Min.   :   0.0                                
 1st Qu.:  31.0                                
 Median : 506.5                                
 Mean   : 829.9                                
 3rd Qu.:1257.0                                
 Max.   :6415.0                                
 Offences.against.Property...Extortion....Col..13.
 Min.   :  0.00                                   
 1st Qu.:  1.00                                   
 Median : 23.00                                   
 Mean   : 68.94                                   
 3rd Qu.: 67.75                                   
 Max.   :637.00                                   
 Offences.against.Property...Robbery....Col..14
 Min.   :   0.00                               
 1st Qu.:   5.75                               
 Median : 121.00                               
 Mean   : 353.06                               
 3rd Qu.: 399.75                               
 Max.   :3382.00                               
 Offences.against.Property...Dacoity....Col..15.
 Min.   :   0.0                                 
 1st Qu.:   1.0                                 
 Median :  66.0                                 
 Mean   : 307.0                                 
 3rd Qu.: 477.2                                 
 Max.   :2175.0                                 
 Offences.against.Property...Prep..and.Assembly.for.Dacoity....Col..16.
 Min.   :   0.0                                                        
 1st Qu.:   0.0                                                        
 Median :  15.0                                                        
 Mean   : 147.5                                                        
 3rd Qu.: 157.0                                                        
 Max.   :1811.0                                                        
 Offences.against.Property...Criminal.Breach.of.Trust....Col..17.
 Min.   :  0.00                                                  
 1st Qu.:  0.75                                                  
 Median : 24.00                                                  
 Mean   : 80.11                                                  
 3rd Qu.: 84.25                                                  
 Max.   :612.00                                                  
 Offences.against.Property...Cheating....Col..18.
 Min.   :   0.00                                 
 1st Qu.:   2.75                                 
 Median :  40.00                                 
 Mean   : 189.72                                 
 3rd Qu.: 232.75                                 
 Max.   :1365.00                                 
 Offences.against.Property...Arson....Col..19.
 Min.   :  0.00                               
 1st Qu.:  0.00                               
 Median :  3.50                               
 Mean   : 19.25                               
 3rd Qu.: 20.75                               
 Max.   :239.00                               
 Offences.against.Property...Burglary....Col..20.
 Min.   :   0.0                                  
 1st Qu.:   5.5                                  
 Median :  74.0                                  
 Mean   : 158.1                                  
 3rd Qu.: 217.8                                  
 Max.   :1356.0                                  
 Total.Offences.against.Property....Col..21.
 Min.   :    0.0                            
 1st Qu.:   73.5                            
 Median : 1009.5                            
 Mean   : 2153.6                            
 3rd Qu.: 3107.0                            
 Max.   :16970.0                            
 Offences.relating.to.Documents...Property.Marks...Counterfeiting....Col..22.
 Min.   :  0.00                                                              
 1st Qu.:  0.00                                                              
 Median :  8.50                                                              
 Mean   : 39.19                                                              
 3rd Qu.: 63.75                                                              
 Max.   :236.00                                                              
 Other.Crime.Against.Women...Cruelty.by.Husband.or.Relatives.of.Husband....Col..23.
 Min.   :   0.0                                                                    
 1st Qu.:   0.0                                                                    
 Median :  23.0                                                                    
 Mean   : 115.7                                                                    
 3rd Qu.: 126.0                                                                    
 Max.   :1098.0                                                                    
 Other.Crime.Against.Women...Insult.to.the.Modesty.of.Women....Col..24.
 Min.   : 0.00                                                         
 1st Qu.: 0.00                                                         
 Median : 1.50                                                         
 Mean   :12.81                                                         
 3rd Qu.:15.25                                                         
 Max.   :75.00                                                         
 Total.Other.Crime.Against.Women...Col..23....Col..24.....Col..25.
 Min.   :   0.0                                                   
 1st Qu.:   0.0                                                   
 Median :  43.0                                                   
 Mean   : 128.5                                                   
 3rd Qu.: 135.8                                                   
 Max.   :1170.0                                                   
 Undertrials.of.offences.against.women..Total.of.Col..5...Col..8...Col..9...Col.23...Col.24.....Col..26.
 Min.   :    0.00                                                                                       
 1st Qu.:   72.25                                                                                       
 Median :  552.50                                                                                       
 Mean   : 1792.22                                                                                       
 3rd Qu.: 2329.00                                                                                       
 Max.   :20186.00                                                                                       
 Other.IPC.Crimes....Col..27. Total.Undertrials..IPC.Crimes.....Col..28.
 Min.   :   0.00              Min.   :    0                             
 1st Qu.:  20.75              1st Qu.:  332                             
 Median : 110.00              Median : 2868                             
 Mean   : 323.83              Mean   : 7877                             
 3rd Qu.: 513.25              3rd Qu.:11979                             
 Max.   :2154.00              Max.   :65897                             

Null Check

                                                                                       Sl..No...Col..1. 
                                                                                                      0 
                                                                                      State.UT..Col..2. 
                                                                                                      0 
                                                                                                    S.U 
                                                                                                      0 
                                                  Offences.affecting.the.Human.Body...Murder....Col..3. 
                                                                                                      0 
                            Offences.affecting.the.Human.Body...C.H..not.amounting.to.Murder....Col..4. 
                                                                                                      0 
                                            Offences.affecting.the.Human.Body...Dowry.Deaths....Col..5. 
                                                                                                      0 
                                       Offences.affecting.the.Human.Body...Attempt.to.Murder....Col..6. 
                                                                                                      0 
                                  Offences.affecting.the.Human.Body...Kidnapping...Abduction....Col..7. 
                                                                                                      0 
                                                    Offences.affecting.the.Human.Body...Rape....Col..8. 
                                                                                                      0 
     Offences.affecting.the.Human.Body...Assault.on.Women.with.Intent.to.Outrage.her.Modesty....Col..9. 
                                                                                                      0 
                                                    Total.Offences.affecting.the.Human.Body....Col..10. 
                                                                                                      0 
                                                Offences.against.Public.Tranquility...Riots....Col..11. 
                                                                                                      0 
                                                         Offences.against.Property...Thefts....Col..12. 
                                                                                                      0 
                                                      Offences.against.Property...Extortion....Col..13. 
                                                                                                      0 
                                                         Offences.against.Property...Robbery....Col..14 
                                                                                                      0 
                                                        Offences.against.Property...Dacoity....Col..15. 
                                                                                                      0 
                                 Offences.against.Property...Prep..and.Assembly.for.Dacoity....Col..16. 
                                                                                                      0 
                                       Offences.against.Property...Criminal.Breach.of.Trust....Col..17. 
                                                                                                      0 
                                                       Offences.against.Property...Cheating....Col..18. 
                                                                                                      0 
                                                          Offences.against.Property...Arson....Col..19. 
                                                                                                      0 
                                                       Offences.against.Property...Burglary....Col..20. 
                                                                                                      0 
                                                            Total.Offences.against.Property....Col..21. 
                                                                                                      0 
                           Offences.relating.to.Documents...Property.Marks...Counterfeiting....Col..22. 
                                                                                                      0 
                     Other.Crime.Against.Women...Cruelty.by.Husband.or.Relatives.of.Husband....Col..23. 
                                                                                                      0 
                                 Other.Crime.Against.Women...Insult.to.the.Modesty.of.Women....Col..24. 
                                                                                                      0 
                                      Total.Other.Crime.Against.Women...Col..23....Col..24.....Col..25. 
                                                                                                      0 
Undertrials.of.offences.against.women..Total.of.Col..5...Col..8...Col..9...Col.23...Col.24.....Col..26. 
                                                                                                      0 
                                                                           Other.IPC.Crimes....Col..27. 
                                                                                                      0 
                                                             Total.Undertrials..IPC.Crimes.....Col..28. 
                                                                                                      0 

Structure

'data.frame':   36 obs. of  29 variables:
 $ Sl..No...Col..1.                                                                                       : int  1 2 3 4 5 6 7 8 9 10 ...
 $ State.UT..Col..2.                                                                                      : chr  "Andhra Pradesh" "Arunachal Pradesh" "Assam" "Bihar" ...
 $ S.U                                                                                                    : chr  "S" "S" "S" "S" ...
 $ Offences.affecting.the.Human.Body...Murder....Col..3.                                                  : int  484 31 1741 6140 2873 113 3265 4108 398 4085 ...
 $ Offences.affecting.the.Human.Body...C.H..not.amounting.to.Murder....Col..4.                            : int  53 4 266 508 196 0 75 189 3 220 ...
 $ Offences.affecting.the.Human.Body...Dowry.Deaths....Col..5.                                            : int  60 0 66 1639 123 0 15 389 0 779 ...
 $ Offences.affecting.the.Human.Body...Attempt.to.Murder....Col..6.                                       : int  331 1 544 4974 1383 22 420 1303 42 1611 ...
 $ Offences.affecting.the.Human.Body...Kidnapping...Abduction....Col..7.                                  : int  50 8 401 1833 294 15 502 855 32 801 ...
 $ Offences.affecting.the.Human.Body...Rape....Col..8.                                                    : int  211 9 318 1537 2565 37 1651 1552 325 1793 ...
 $ Offences.affecting.the.Human.Body...Assault.on.Women.with.Intent.to.Outrage.her.Modesty....Col..9.     : int  25 0 57 315 290 24 92 251 10 268 ...
 $ Total.Offences.affecting.the.Human.Body....Col..10.                                                    : int  1214 53 3393 16946 7724 211 6020 8647 810 9557 ...
 $ Offences.against.Public.Tranquility...Riots....Col..11.                                                : int  0 0 17 166 37 0 77 93 0 139 ...
 $ Offences.against.Property...Thefts....Col..12.                                                         : int  580 23 1202 2831 483 32 613 1740 21 1441 ...
 $ Offences.against.Property...Extortion....Col..13.                                                      : int  19 4 59 326 14 0 66 109 1 228 ...
 $ Offences.against.Property...Robbery....Col..14                                                         : int  103 13 127 1743 328 21 231 502 5 463 ...
 $ Offences.against.Property...Dacoity....Col..15.                                                        : int  88 0 76 1289 281 3 296 550 2 555 ...
 $ Offences.against.Property...Prep..and.Assembly.for.Dacoity....Col..16.                                 : int  27 0 0 363 24 0 47 187 0 155 ...
 $ Offences.against.Property...Criminal.Breach.of.Trust....Col..17.                                       : int  23 0 25 219 76 0 319 211 4 206 ...
 $ Offences.against.Property...Cheating....Col..18.                                                       : int  106 0 22 413 161 22 23 184 2 802 ...
 $ Offences.against.Property...Arson....Col..19.                                                          : int  1 19 39 58 13 0 11 20 0 41 ...
 $ Offences.against.Property...Burglary....Col..20.                                                       : int  97 10 270 290 373 0 152 253 8 155 ...
 $ Total.Offences.against.Property....Col..21.                                                            : int  1044 69 1820 7532 1753 78 1758 3756 43 4046 ...
 $ Offences.relating.to.Documents...Property.Marks...Counterfeiting....Col..22.                           : int  34 0 29 74 44 0 84 33 0 62 ...
 $ Other.Crime.Against.Women...Cruelty.by.Husband.or.Relatives.of.Husband....Col..23.                     : int  102 0 159 642 32 0 138 77 5 410 ...
 $ Other.Crime.Against.Women...Insult.to.the.Modesty.of.Women....Col..24.                                 : int  8 0 1 27 14 0 0 16 0 16 ...
 $ Total.Other.Crime.Against.Women...Col..23....Col..24.....Col..25.                                      : int  110 0 160 669 46 0 138 93 5 426 ...
 $ Undertrials.of.offences.against.women..Total.of.Col..5...Col..8...Col..9...Col.23...Col.24.....Col..26.: int  406 9 601 4160 3024 61 1896 2285 340 3266 ...
 $ Other.IPC.Crimes....Col..27.                                                                           : int  345 4 197 503 732 43 297 0 57 134 ...
 $ Total.Undertrials..IPC.Crimes.....Col..28.                                                             : int  2747 126 5616 25890 10336 332 8374 12622 915 14364 ...

Renaming the attributes

 [1] "Sl.no"                                              
 [2] "State/UT"                                           
 [3] "SoU"                                                
 [4] "Murder"                                             
 [5] "C.H"                                                
 [6] "Dowry"                                              
 [7] "Attempt to murder"                                  
 [8] "Kidnapping & Abduction"                             
 [9] "Rape"                                               
[10] "Assault on Women with Intent to Outrage her Modesty"
[11] "Total Offences affecting the Human Body"            
[12] "Riots"                                              
[13] "Thefts"                                             
[14] "Extortion"                                          
[15] "Robbery"                                            
[16] "Dacoity"                                            
[17] "Prep. and Assembly for Dacoity"                     
[18] "Criminal Breach of Trust"                           
[19] "Cheating"                                           
[20] "Arson"                                              
[21] "Burglary"                                           
[22] "Total Offences against Property"                    
[23] "Counterfeiting"                                     
[24] "Cruelty by Husband or Relatives of Husband"         
[25] "Insult to the Modesty of Women"                     
[26] "Total Other Crime Against Women"                    
[27] "Undertrials of offences against women"              
[28] "Other IPC Crimes"                                   
[29] "Total_Undertrials"                                  

Visualization

DV

Histogram


Upon looking at the histogram plots it is observed that all the plots here are right skewed and also we can see that there’s a state having more number of cases under trial for crime against woman.

Scatterplot


   Sl.no       State/UT
1      4          Bihar
2      5   Chhattisgarh
3      8        Haryana
4     10      Jharkhand
5     13 Madhya Pradesh
6     14    Maharashtra
7     19         Odisha
8     21      Rajasthan
9     26  Uttar Pradesh
10    28    West Bengal


Here dataset has been filtered such that it has all states which have cases that are greater than the mean of Total_under trials This plot helps us to see that UP tops in the list of having more number of criminal cases against women

Barplot


   Sl.no       State/UT
1      4          Bihar
2      5   Chhattisgarh
3      8        Haryana
4     10      Jharkhand
5     13 Madhya Pradesh
6     14    Maharashtra
7     19         Odisha
8     21      Rajasthan
9     26  Uttar Pradesh
10    28    West Bengal


With the before filtered data set and with the help of this plot we can see UP topping the list of having more number of cases against property

Correlation

[1] "Rape"                                               
[2] "Assault on Women with Intent to Outrage her Modesty"
[3] "Cruelty by Husband or Relatives of Husband"         
[4] "Insult to the Modesty of Women"                     


Download

---
title: "Prison"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    social: menu
    theme: united
    source_code: embed
    storyboard: TRUE
---

```{r setup, include=FALSE}
libraries= c("flexdashboard","lattice","DT","dplyr","corrplot","ggplot2")
lapply(libraries,require,character.only=TRUE)
data2=read.csv("D:/BU/Sem 2/R/Rdata/prison.csv",header = TRUE)
attach(data2)
```

# Home

The following data "State/UT-wise Under trial Prisoners by Type of Offences under Indian Penal Code (IPC) as on 31st December, 2020" has been taken from  data.gov.in. In the following sections we will see EDA through which inferences are taken and some visualization of this data set.

## DD{.tabset}




### Summary

Dimension
```{r}

dim(data2)

```

Summary
```{r}

summary(data2)

```

### Null Check
```{r}

colSums(is.na(data2))

```


### Structure
```{r}

str(data2)

```


### Renaming the attributes
```{r}
names(data2)=c("Sl.no","State/UT","SoU","Murder","C.H","Dowry",
               "Attempt to murder","Kidnapping & Abduction","Rape",
               "Assault on Women with Intent to Outrage her Modesty" ,
               
               "Total Offences affecting the Human Body",
               "Riots","Thefts","Extortion","Robbery","Dacoity",
               "Prep. and Assembly for Dacoity","Criminal Breach of Trust",
               "Cheating","Arson","Burglary","Total Offences against Property",
               "Counterfeiting","Cruelty by Husband or Relatives of Husband",
               "Insult to the Modesty of Women","Total Other Crime Against Women",
               "Undertrials of offences against women","Other IPC Crimes",
               "Total_Undertrials")
names(data2)
attach(data2)

```


# Visualization

## DV{.tabset}

### Histogram


```{r}
par(  mfrow=c(2,2),  mar=c(4,4,1,0) )
hist(`Total_Undertrials`, breaks=10 , col=rgb(0,0,1,0.5) , 
     xlab="Total_Undertrials" , ylab="" , main="")


hist(`Undertrials of offences against women`, breaks=30 , col=rgb(0,0,1,0.5) , xlab="Undertrials of offences against women" , ylab="" , main="")
hist(`Assault on Women with Intent to Outrage her Modesty`, breaks=20 , col=rgb(0,0,1,0.5) , 
     xlab="Assault on Women with Intent to Outrage her Modesty" , ylab="" , main="") 

hist(`Total Other Crime Against Women`, breaks=25 , col=rgb(0,0,1,0.5) , 
     xlab="Total Other Crime Against Women" , ylab="" , main="")
```
```{r}
par(  mfrow=c(2,2),  mar=c(4,4,1,0) )
hist(`Rape`, breaks=20 , col=rgb(0,0,1,0.5) , 
     xlab="Rape" , ylab="" , main="") 
hist(`Dowry`, breaks=30, col=rgb(0,0,1,0.5) , 
     xlab="Dowry" , ylab="" , main="") 
hist(`Cruelty by Husband or Relatives of Husband`, breaks=25 , col=rgb(0,0,1,0.5) , 
     xlab="Cruelty by Husband or Relatives of Husband" , ylab="" , main="")
hist(`Insult to the Modesty of Women`, breaks=30   , col=rgb(0,0,1,0.5) , 
     xlab="Insult to the Modesty of Women" , ylab="" , main="")

```
```{r}
#par(  mfrow=c(2,2),  mar=c(4,4,1,0) )
#hist(`Undertrials of offences against women`, breaks=20 , col=rgb(0,0,1,0.5) , xlab="Undertrials of offences against women" , ylab="" , main="")

```

Upon looking at the histogram plots it is observed that all the plots here are right skewed and also we can see that there's a state having more number of cases under trial for crime against woman. ### Scatterplot ```{r} U=filter(data2,SoU=="S") a=mean(U$Total_Undertrials) A=filter(U,Total_Undertrials > a) State=as.factor(A$Sl.no) ggplot(A)+geom_point(mapping = aes(x=State,y=`Undertrials of offences against women`))+ ggtitle(label = "States vs Undertrials of offences against women") ```
```{r} d=subset(A,select = c(1,2)) d ```
Here dataset has been filtered such that it has all states which have cases that are greater than the mean of Total_under trials This plot helps us to see that UP tops in the list of having more number of criminal cases against women ### Barplot ```{r} State=as.factor(A$Sl.no) ggplot(A, aes(State,`Total Offences against Property`)) + geom_bar(stat = "identity", color = "purple") + theme(axis.text.x = element_text(angle = 70, vjust = 0.5, color = "green")) + ggtitle("State`V`Total Offences against Property") + theme_bw() ```
```{r} d=subset(A,select = c(1,2)) d ```
With the before filtered data set and with the help of this plot we can see UP topping the list of having more number of cases against property ### Correlation ```{r} b=subset(A,select = c(9,10,24,25)) names(b) ```
```{r} names(b)=c("R","A","C","I") corrplot(cor(b),method = "number",shade.col=NA, tl.col="black",tl.srt=0, mar=c(4,2,4,0)) ``` # Download ```{r} datatable(data2,extensions='Buttons',options=list(dom="Bftrip",buttons=c('copy','print','csv','pdf'))) ```