The application is designed to show judging teams distribution in Polish courts. Application is a part of SAOS project which is described on following websites:
User can select particular court from the database, see judges network and several statistics. Application in still under development.
The input data for this application is data of polish judges and judgments. This app uses data downloaded through API and transformed to more convenient format. The input are following tables with corresponding variables:
judgments | judges | divisions | judges.net | |
---|---|---|---|---|
V1 | judgmentID | judgmentID | CourtCode | name1 |
V2 | judgmentType | JudgeName | CourtName | name2 |
V3 | judgmentDate | specialRoles | DivisionCode | Sex1 |
V4 | judgmentYear | CourtCode | DivisionName | Sex2 |
V5 | CourtCode | DivisionCode | NA | judgmentID |
V6 | DivisionCode | judgmentDate | NA | judgmentDate |
V7 | NA | judgmentYear | NA | judgmentYear |
V8 | NA | JudgeSex | NA | specialRole1 |
V9 | NA | NA | NA | specialRole2 |
V10 | NA | NA | NA | CourtCode |
V11 | NA | NA | NA | DivisionCode |
Description of each variable in above table is following:
DECISION/RESOLUTION/SENTENCE/REGULATION/REASONS
YY-MM-DD
judgmentYear
JudgeName
so some rows are missingJudgeName
for first judge. Used to build network of judges. Node of the networkJudgeName
for second judge. Used to build network of judges. Node of the networkJudgeSex
, additional attribute for name1
nodeJudgeSex
, additional attribute for name2
nodeSpecialRolse
, additional attribute for name1
nodeSpecialRolse
, additional attribute for name2
nodeTest bookmark.
In this bookmark user can see the network of judges in selected court. Each node (circle or traingle) refers to one judge. Link between 2 judges means that they have been in the same judging team minimum once. Each division in the court is marked with different colour. Circles refers to women and triangles to men.
There the same network as in Net mark bookmark can be found. There is difference only with visualizing data. Each node is coloured with colour reffering to division(s) the judge is assigned to.
In this bookmark some summarizing statistics can be found.
Plot shows number of judges in all divisions in specified court. Graph spans with years of judgments that are found in database for particular court.
Plot show numbe of unique judges working in all divisions in specified court. Year when judge works means that his/her name occured in minimum one judgment with spcified judgment date.
Histogram reflects female judges preferences in particular case. This preference is calculated as follows:
$\frac{N{female}}{N{female}+N_{male}}$
so it is in range {0,1}
. Red vertical line shows mean female preference for court.
Histogram shows number of direct connections for each judge in court. In the language of graphs this is node degree distribution.
Histogram shows number of times that two judges in court have been in the same judging team. In the language of graphs this is histogram of weights of edges.
Plot shows what percentage of judges in court is included in maximum component of the network. Maximum component means that between all possible pairs of nodes (judges) in that component exists minimum one connection (through other judges and links between them).
Plot shows diversity in judging teams in particular court. This diversity is defined as follows:
$diversity=\frac{N{links}}{N{possible links}}$
where:
$N{links}$ - number of unique links/edges between judges $N{possible links}$ - maximum number of links that could exist in court for this number of judges in court and configuration of judging teams (number of judges in each case). Points on the plot are divided into years when judgment was made.
Top chart show top 10 (or less if there is not enough in the court) judges in the number of cases they have been taking part.
This file consists functions that are used to transform, analize and visualise the data. Those functions can be also used outside the shiny application.
Function takes data from judges
table for specified court as an input. Then it creates a list of 10 (or less if not possible) judges that have the maximum number of cases in chosen court. This function is used to plot Top chart in application. Function returns data frame with columns JudgeName
and N.of.judgments
.
Function takes data from judges
and judges.net
tables fo specified court as an input. Function than creates a network of judges. This network is not simplified, i.e. there are multiple links between judges consisting information about judgments. The output of the function is network (graph).
Function takes network from g.court
function as an input. Then it simplifies the network in following manner:
Function returns simplified network (graph).
Function takes simplified graph from g.simplify
function as an input. Then it returns matrix with TRUE/FALSE
values that specify whether or not each judge (node of the graph) belongs to division (each division is in new column).
Function takes simplified graph from g.simplify
function and matrix from g.mark.matrix
function as an input. Then, for each matrix column (each division in specified court) it creates the level of the list with id of nodes which belongs to this division. Then function applies different colour to each division as a name of the level. Colours are chosen from brewer pallete with alpha channel added (that some level of transparency to the node). Function returns a mentioned list. This list is used to colour groups in Net mark
bookmark in shiny application.
Function takes simplified network (graph) from g.simplify
function as an input. Then the function assign a coloured pie chart for each node in given graph. Different colours correspond to different divisions. Pie chart is equally divided into parts. Function returns simplified graph with added pie chart.
Function takes data from judges
and judges.net
table for specified court as an input. It also takes simplified graph from g.simplify
function. Then the function calculates diversity of judging teams (described above) for each year in particular court. The output is data frame with year
and coop
columns.
Function takes data from judges
table for specified court as an input. Then it calculates number of judgments for each year, corresponding to judgment date. Function returns data frame with columns year
and number.judgments
judgm.year<-function(subset.judges.c){ sub<-subset.judges.c[!duplicated(subset.judges.c$judgmentID),] df<-count(sub,"judgmentYear") names(df)<-c("year","number.judgments") df }
Function takes data from judges
table for specified court as an input. Than it calculates numbe of judges for each year, corresponding to judgment date. Function returns data frame with columns 'year' and 'number.judges`.
Function takes network(graph) from g.court
for specified court as an input. Than the function calculates maximum component for that network for each year, corresponding to judgment date. Function returns data frame with columns year
and size.max.component
.
Function takes data from judges
table as an input, but only rows where JudgeSex is assigned (M/F
value). Then it calculates fraction $\frac{N{female}}{N{female}+N{male}}$, where $N{female}$ and $N{male}$ is number of women and men, for each case. Additionally, the function calculates fraction of $\frac{N{female}}{N{female}+N{male}}$ for whole court. The output is plot in format of ggplot package.
This script contains functions that help to compute/visualize particular things but have more general usage that this application.
External function that takes list of ggplot plots as an input and arrange them in one multiplot with number of columns specified in cols
parameter. The output is one multiplot graphics.
External function that takes colours vector (color name / hexadecimal #rrggbb
format / positive integer i
meaning palette()[i]
) and level of alpha (from {0,1}
range) meaning the level of transparency as an input. Function returns vector of colours in RGB format with added alpha channel.
Function takes list of division names and colours (as level names) as input. Function creates graph and returns legend for the court divisions as a plot arranged in grid.
Function takes network ( simplified graph) from g.simplify
function, computed layout for the network and list of groups from g.mark.list
function as an input. Drawing of network with marked divisions is an output.
Function takes network ( simplified graph) from g.simplify
function, computed layout as an input. Then is prints out drawing of network with pie chart representing each node. Colours of the node corresponds with divisions judge is assigned to. Drawing of the network is an output of that function.
Those functions add extra shapes to be plotted in network (graph) as nodes: circles, traingles and stars.
Function that takes number of judges in court and array with number of judges in particular cases as an input. Then, the function calculates how many unique links (so sitting in the same judgment team) can be in such network with given parameters. The output is a number of maximum possible links in this network.
Function takes array (array
) with number of judges in particular cases (in specified court), number of all judges (njudges
) in court, array (ordered
) of ordered elements from array
and value (nnext
) pointing to next element to be checked in array
as an input. Then, recursively, function order elements from the array
and returns it altogether with the next element.