Chunk setup

Set your working directory. Due to encoding issues, we need to set locale to “Norwegian_Bokmål_Norway”.

knitr::opts_chunk$set(warning=FALSE, message=FALSE, dpi = 300,  dev='png', fig.path = "figures_fr/")
Sys.setlocale(locale = 'Norwegian Bokmål_Norway')
## Warning in Sys.setlocale(locale = "Norwegian Bokmål_Norway"): using locale code
## page other than 65001 ("UTF-8") may cause problems
## [1] "LC_COLLATE=Norwegian Bokmål_Norway.utf8;LC_CTYPE=Norwegian Bokmål_Norway.1252;LC_MONETARY=Norwegian Bokmål_Norway.utf8;LC_NUMERIC=C;LC_TIME=Norwegian Bokmål_Norway.utf8"

Load packages used in the analysis

library(rvest) # for scraping html-files
library(tidyverse) # ggplot and datamangement
library(haven) # for import of data
library(readxl) # reading xl files
library(ggrepel) # for labelling plots
library(marginaleffects) # marginal effects 
library(gt) # tables
library(gtExtras) # tables
library(modelsummary) # regression tables
library(broom) # tidy regression results
library(gghalves) # for plotting the boxplots with points
library(ggbeeswarm) # for plotting the boxplots with points
library(scales) # for plotting

1. Description

The code in this document generate the data and results reported in Differential engagement with constitutional and international fundamental rights on the Supreme Court of Norway. The first part of this document creates the dataset and the second part reports the analysis, as well as complementary results.

The final data is created from two different sources. The following lists the most important variables that we use from each dataset and that we use for further coding purposes.

2. The Rights dataset

We created a dataset Rights that links rights articles (e.g. EHCR art. 6) to its substantive content (e.g. right to a fair trial) and then categorized each article in six non-exclusive categories based on the Comparative Constitutions Project (CCP) to measure the substantive content of the fundamental right. The rights that are included in the data are the fundamental rights that Norway have ratified through the Human Rights Act, with later amendments (see https://lovdata.no/dokument/NLE/lov/1999-05-21-30)

The six rights categories are:

The CCP already coded the Norwegian Constitution. We coded each article in ECHR using a dictionary-based approach and we hand-coded the ICCPR, ICESCR, CRC and CEDAW.

In total, the dataset consist of 190 rights articles. The data is created by running the rights.R-script below. In the analysis we use this data to examine how much judges use different FR laws under different categories of rights.

3. Data collection: creating law citation data from unstrutured text data from LovdataPro

Using a LovdataPro account we identified fundamental rights cases following this procedure. We used a set of selection criteria to create a subset of fundamental rights cases:

This results in 233 decisions with references to fundamental rights laws from 2008-2022.

We download all cases, including metadata, as HTML-files and extract information from decisions using the rvest package (Wickham 2023) in the statistical software R.

3.1 Get html files

From each decision we extract metadata on the type of decision (judgement/interlocutory judgment), date of the decision, case keywords, case summary, case proceedings, case parties, judge panel, and last updated.

The table function extracts metadata from Lovdatata’s summary field

table <- function(x) {
  x %>%
    html_element("table") %>%
    html_table() %>%
    pivot_wider(names_from = X1, values_from = X2)
}

Apply table function to cases:

metadata <- lapply(cases, table)

Turn metadata into a dataframe object:

df_summary <- bind_rows(metadata)

df_summary have nine columns. The nine columns are (english translation): short description

  • Instans (Authority): name of court - type of decision
  • Dato (Date): decision date
  • Publisert (Published): casenumber
  • Stikkord (Keywords): n words describing area(s) of law, facts and legal question
  • Sammendrag (Summary): decision summary
  • Saksgang (Proceedings): case history
  • Parter (Parties): appellant v. respondent
  • Forfatter (Author): judge names
  • Sist oppdatert (Last update): last time decision text was updated

We create different casenumbers variables for later merging purposes:

df_summary <- df_summary %>% 
  mutate(Publisert = str_replace_all(Publisert, "\\–", "\\-"))

df_summary <- df_summary %>% 
   mutate(hr_number = str_extract_all(Publisert, "\\w+\\-\\d+\\-\\d+\\-\\w"),
          rt_number = str_extract_all(Publisert, "Rt\\-\\d+\\-\\d+"),
          published = ifelse(rt_number == "character(0)", as.character(hr_number), as.character(rt_number)))

We use information in df_summary to create case-level variables of interest

  • type_of_decision: two different types and three cases that we will remove. The relevant information is contained in the variable Instans.

Cases in the remove from sample category are the Supreme Court’s are one-judge decisions on postponement of processing of appeals (HR-2009-656-F and HR-2009-746-F). One case is is SCONs “betenkning” to the Norwegian parliament (HR-2021-655-P).

judgment <- c("Dom|Dom og kjennelse|Dom og orskurd") # cases that are both are classified as judgment
interlocutory_judgment <- ("Kjennelse|Orskurd")
remove_from_sample <- ("Beslutning|Betenkning")

df_summary <- df_summary %>%
  mutate(
    type_of_decision = case_when(
      grepl(judgment, Instans) ~ "Decision",
      grepl(interlocutory_judgment, Instans) ~ "Order",
      grepl(remove_from_sample, Instans) ~ "remove_from_sample"
    )
  )
  • dissent case: whether case is decided with dissenting opinions or not. This is information is available in the string variable Forfatter (Author), which lists judge names and dissenters.
dissent <- c("Dissens|dissens|Særmerknader") # this id all types of disagreement

df_summary <- df_summary %>%
  mutate(dissent_case = ifelse(grepl(dissent, Forfatter), "Dissents", "Consensus"))
  • type of panel: five-justice panel, grand chamber or plenary. In the string variable Publisert “A” is short for “Avdeling” (regular cases decided in grand chamber), “S” is short for “Storkammer” (case decided in strengthened panel with 11 judges or less), and “P” is short for Plenum (cases decided by all judges on the court in plenary).
five_judge <- c("A")
grand_chamber <- ("S")
plenary <- ("P")

df_summary <- df_summary %>%
  mutate(
    type_of_panel = case_when(
      grepl(five_judge, Publisert) ~ "Five-judge panel",
      grepl(grand_chamber, Publisert) ~ "Grand chamber",
      grepl(plenary, Publisert) ~ "Plenary"
    )
  )
  • Civil or criminal law: In case keywords, criminal law cases are identified by the word “straff” (criminal), civil law cases are identified as not including this word in case keyword.
df_summary <- df_summary %>%
  mutate(type_of_law = ifelse(str_detect(tolower(Stikkord), "straff"), "Criminal law", "Civil law"))

There are four plenary cases that concern the impartiality of the Supreme Court justices participating in the decision. We want to remove these from the analysis later on. Here we simply identify them.

df_summary <- df_summary %>% 
 mutate(plenary_impartiality = case_when(type_of_panel == "Plenary" & str_detect(tolower(Stikkord), "habilitet") ~ "Yes"))

3.1.2 Get paragraphs of text

This code extracts paragraphs of text and casenumber and create a dataframe with three variables

  • case = casenumber

  • text = paragraph text and hypertext

  • ref_link = law citation hyperlink

par <- cases %>% 
  map_df(~{
    case <- .x %>% html_nodes("h1") %>% html_text()
    nodes <-
      xml2::xml_find_all(
        .x,
        ".//p[preceding-sibling::div[@align='center']] | .//table[preceding-sibling::div[@align='center']] | .//a[preceding-sibling::span]|.//a[following-sibling::span]"
      )
    text <- rvest::html_text(nodes)
    text <- gsub("_", "", text)
    ref_link <- rvest::html_attr(nodes, "href")
    tibble(case, text, ref_link)
  }
  )

This code generate id variable that identify paragraphs within case. Data in the variable text and that have missing values in par_paragraph is from the summary of the decision and is not part of the decision itself. The variable link_name extract the hypertext associated with the hyperlinks.

par <- par %>%  
  mutate(par_paragraph = str_extract(text, "(^\\(\\d+)\\)"),
         par_paragraph = str_replace_all(par_paragraph, "[(]|[)]", ""),
         par_paragraph = as.numeric(as.character(par_paragraph)))

par <- par %>% 
  mutate(link_name = ifelse(!str_detect(text, "(^\\(\\d+)\\)"), text, NA))


par <- par %>%
  group_by(case) %>% 
  fill(par_paragraph)

Paragraphs with text:

par_text <- par %>%
  dplyr::select(-c(ref_link, link_name)) %>% # remove ref_link
  filter(str_detect(text, "(^\\(\\d+)\\)")) %>%
  mutate(par_text = gsub("^\\(\\d+\\)", "", text))

Paragraphs with law citations:

par_references <- par %>% 
  dplyr::select(-text) %>% 
  filter(!is.na(par_paragraph)) %>% 
  filter(!is.na(ref_link))

Join par_text and par_references in a new data frame where ref_link is the unit of observation and belongs to a paragraph of text (par_paragraph and par_text) which belongs to a case. Paragraphs without ref_link are NA in ref_link.

text_and_links <- par_text %>% 
  full_join(par_references, by = c("case", "par_paragraph")) %>% 
  dplyr::select(-text) 

remove(par_references, par_text, par, cases) # remove three df's that we do not need anymore

Make Publisert variable to merge with df_summary:

publisert <- unique(df_summary$Publisert)
publisert <- paste(publisert, collapse = "|")
text_and_links <- text_and_links %>%
  mutate(Publisert = str_extract_all(case, publisert)) %>% 
  unnest(cols = Publisert)

3.1.3 Identify judges to make par_judge variable

We use information in the string-variable par_text to identify the author of the paragraph text.

# text_and_links <- text_and_links %>% 
#   mutate(par_text = gsub("Dommer :", "Dommer", par_text))

Text patterns to identify judges:

text_and_links <- text_and_links %>%
  mutate(par_judge = ifelse(
    grepl(
      "^ *Domm[ea]r[ne]* .*:.*$|^ *Justit[ui]arius .*:.*$|^ *Kst\\. domm[ea]r .*:.*$",
      par_text
    ),
    gsub(
      "^ *(Domm[ea]r[ne]*|Justit[ui]arius|Kst\\. domm[ea]r) (.*?):.*$",
      "\\2",
      par_text
    ),
    NA
  ),
  par_judge = strsplit(gsub("\\.", "", par_judge), " og |, ")) 

3.1.5 Fill judge variable

Now, we fill the par_judge variable. Remember that we want to separate the judgement part from the judge author part.

text_and_links <- text_and_links %>%
  mutate(
    par_judge = as.character(par_judge)) %>%
  fill(par_judge)

Create judge order variable for coding of dissenting opinions

judge_order <- text_and_links %>%
  group_by(case) %>% 
  distinct(par_judge) %>% 
  mutate(
    judge_order =  seq_along(par_judge)) 

text_and_links <- text_and_links %>% 
  inner_join(judge_order, by = c("case", "par_judge"))

3.1.4 Make par_section variable that id subsections of decision

We create a variable that identify subsections in the decision. The structure of each decision looks like this:

  • Syllabus
    • Main legal question
    • Proceedings
    • The plaintiff’s claims
      • Legal arguments
      • Legal claims
    • The respondent’s claims
      • Legal arguments
      • Legal claims
  • Main opinion
    • Majority opinion
      • Conclusion
    • Minority opinion(s)
      • Conclusion
    • Votes
  • Judgement

Syllabus refers to the introductory parts of decisions. It normally consists of 1) a general statement as to what is the main legal question in the case, 2) proceedings, the legal history of the case, 3) the plaintiffs’ claim, and 4) the respondents’ claim. From the syllabus section our main interest is to identify the parties fundamental rights arguments.

The following text patterns are gathered from Bjørnebekk and Johannesson (2016) and identify the start of each section. The syllabus section is identified by starting at par_paragraph 1.

Main opinion text patterns:

main_opinion <-
  c("^ *Eg går så over til å gjere greie for mitt syn på saka|^ *Eg går no over til å gjere greie for mitt syn på saka|^ *Eg går no over til å gi uttrykk for mitt syn på habilitetsspørsmåla|^ *Jeg er kommet til|^ *Jeg har kommet til|^ *Min vurdering av saken|^ *Jeg ser langt på vei saken på samme måte som de tidligere retter|^ *Jeg starter med å se|^ *Jeg finner at|^ *Jeg bemerker at saken|^ *Mitt syn på saken|^ *Eg er komen til|^ *Mitt syn på saka|^ *Egne bemerkninger|^ *Jeg ser først på|^ *Jeg ser slik på saken:|^ *Jeg er – under atskillig tvil – kommet til at anken fører frem|^ *Jeg er når det gjelder utmålingen |^ *Jeg er blitt stående ved at anken bør tas til følge|^ *Jeg går nå over til å gi uttrykk for mitt syn på saken|^ *Jeg finner det naturlig å behandle anken over saksbehandlingen først|^ *Høyesteretts syn på saken")

Judgement text patterns:

judgement <- c("^ *Etter stemmegivningen avsa Høyesterett denne|^ *Etter røystinga sa Høgsterett slik|^ *Kjennelsen er enstemmig")

Votes text patterns:

votes_1 <- c("^ *Eg røystar etter dette|[Jj]eg stemmer for|^dom:$|^ *Jeg stemmer etter dette|^ *Etter dette stemmer jeg for|^Da jeg er i mindretall, former jeg ingen konklusjon")

Text patterns that identify judges who join opinions, i.e., who do not write their own opinions

judge_join_opinion <-
  c(
    " *\\:\\sLikeså\\.| *:\\sDet same\\.| *:\\sJeg er i det vesentlige og i resultatet enig med \\w+\\, dommer \\w+\\.| *:\\sJeg er i det vesentlige og i resultatet enig med \\w+\\.| *:\\sEg er i det hovudsaklege og i resultatet einig med \\w+\\, dommar \\w+\\.| *:\\sEg er i det hovudsaklege og i resultatet einig med \\w+\\.| *\\:\\sSom dommer \\w+\\."
  )
text_and_links <- text_and_links %>%
  mutate(join_opinion = case_when(grepl(judge_join_opinion, par_text) ~ "Join opinion"))

Create the par_section variable:

text_and_links <- text_and_links %>%
  mutate(
    par_section = case_when(
      judge_order == 1 & grepl(main_opinion, par_text) ~ "Main opinion",
      grepl(judgement, par_text) ~ "Judgement",
      grepl(votes_1, par_text) ~ "Vote",
      grepl(judge_join_opinion, par_text) ~ "Join opinion",
      par_paragraph == 1 ~ "Syllabus",
      judge_order != 1 & !grepl(judge_join_opinion, par_text) ~ "Dissenting opinion"
    )
  )

Fill par_section variable:

text_and_links <- text_and_links %>% 
  fill(par_section)

Recode dissenting opinions with more than one dissent

text_and_links <- text_and_links %>%
  group_by(case, par_section) %>% 
  mutate(dissent_order =  match(par_judge, unique(par_judge))) %>% 
  ungroup()

text_and_links <- text_and_links %>% 
  mutate(par_section = ifelse(par_section == "Dissenting opinion", paste(par_section, dissent_order, sep = " "), par_section))

To code characteristics of the parties claims we combined regular expressions and manual coding. We collected data manually on the last paragraph number in the syllabus, the first and last paragraph number in the plaintiffs’ claims. From these three numbers we identified the syllabus sections of all decisions and then coded which paragraphs that are plaintiff claims and respondent claims.

Read syllabus data:

Make case number for merging

syllabus <- syllabus %>%
  mutate(number = str_replace_all(case, "[^\\w\\d]", ""))

Do the same in the text_and_link data

text_and_links <- text_and_links %>%    
  mutate(number = str_replace_all(case, "[^\\w\\d]", ""))

Merge syllabus data with text_link_summary data.

text_and_links <- text_and_links %>%   
  left_join(syllabus, by = "number") 

Three cases that do not merge are cases that we want to remove from the sample. They are:

  • Norges Høyesterett - Beslutning. HR-2009-656-F

  • Norges Høyesterett - Beslutning. HR-2009-746-F

  • Norges Høyesterett - Betenkning HR-2021-655-P

Make syllabus section variables:

text_and_links <- text_and_links %>%    
  mutate(
    syllabus_sections = case_when(
      par_paragraph >= plantiff_start &
        par_paragraph <= plaintiff_ends ~ "Plaintiff",
      par_paragraph > plaintiff_ends &
        par_paragraph <= syllabus_ends ~ "Respondent",
      par_paragraph == 1 | par_paragraph == 2 & grepl("Saka gjeld|Saken gjelder", par_text) ~ "Main question"
    )
  ) 

Make detailed case section variable

text_and_links <- text_and_links %>%
  mutate(
    syllabus_sections = ifelse(
      is.na(syllabus_sections) &
        par_paragraph < syllabus_ends,
      "Case history",
      syllabus_sections
    ),
    section_detailed = ifelse(is.na(syllabus_sections), join_opinion, syllabus_sections),
    section_detailed2 = ifelse(is.na(section_detailed), par_section, section_detailed),
    section_detailed2 = ifelse(par_section == "Judgement", par_section, section_detailed2)
  ) 

Remove three variables we do not need anymore

text_and_links <- text_and_links %>% 
  dplyr::select(-c(join_opinion, section_detailed, syllabus_sections))

The section_detailed2 variable is wrong for 44 cases

check <- text_and_links %>% filter(section_detailed2 == "Syllabus" &  par_paragraph>syllabus_ends)
length(unique(check$case.x))
## [1] 44

Recode section_detailed2 to “Main opinion” if category equal syllabus and par_paragraph (paragraph number) is bigger than the number in syllabus_ends.

text_and_links <- text_and_links %>% 
  mutate(section_detailed2 = ifelse(section_detailed2 == "Syllabus" &  par_paragraph>syllabus_ends, "Main opinion", section_detailed2))

Running the test again, we find 0 errors

check <- text_and_links %>% filter(section_detailed2 == "Syllabus" &  par_paragraph>syllabus_ends)
length(unique(check$case.x))
## [1] 0

We change four judgenames for later merging purposes “Schei_C” == Schei, Endresen, C == Endresen, Stabel, I == Stabel, Øie_C == Øie if date > feb 2016.

text_and_links <- text_and_links %>%
  mutate(jfamname = case_when(par_judge == "Schei" ~ "Schei_C",
                               par_judge == "Endresen" ~ "Endresen, C",
                               par_judge == "Stabel" ~ "Stabel, I",
                               par_judge == "Øie" & str_detect(par_text, "Justitiarius")  ~ "Øie_C",
                               TRUE ~ as.character(par_judge)))

3.3 Create a FR law dictionary that pick ups law citiations that are left out

By eyeballing the citation and text data, we can see that not all law citations in the decisions are embedded as hyperlinks in the HTML files.

More systematic examination reveal quite large discrepancies between actual citations and hyperlinks.

To illustrate, from the extracted hyperlinks we identify 2562 references to ECHR

text_links_summary %>%
  count(law_name) %>%
  filter(law_name == "European Convention on Human Rights")
## # A tibble: 1 x 2
##   law_name                                n
##   <chr>                               <int>
## 1 European Convention on Human Rights  2562

Yet searching for the text pattern “ECHR article \d+” in the same data recovered 4088 mentions.

sum(str_count(text_links_summary$par_text,"EMK artikkel| EMK art."))
## [1] 4088

Similarly, from extracted hyperlinks we discovered 1386 citations to the Norwegian constitution

text_links_summary %>%
  count(law_name) %>%
  filter(law_name == "The Constitution of the Kingdom of Norway")
## # A tibble: 1 x 2
##   law_name                                      n
##   <chr>                                     <int>
## 1 The Constitution of the Kingdom of Norway  1386

Yet searching for the text pattern “Grunnloven § \d+|Grunnlova § \d+” in the same data we recover 3416 mentions.

sum(str_count(text_links_summary$par_text,"Grunnloven § \\d+|Grunnlova § \\d+"))
## [1] 3416

For UN convention om the rights of the child we find 293 citations

text_links_summary %>%
  count(law_name) %>%
  filter(law_name == "Convention on the Rights of the Child")
## # A tibble: 1 x 2
##   law_name                                  n
##   <chr>                                 <int>
## 1 Convention on the Rights of the Child   293

and 404 mentions

sum(str_count(text_links_summary$par_text,"barnekonvensjonen artikkel| barnekonvensjonen art."))
## [1] 404

The simplest explanation for the difference between hyperlinks and law mentions is that Lovdata forget to embed law mentions as hypertext.

When judges write opinions they reference the same laws in different ways (e.g. ECHR art. 8 and ECHR article 8). The many different ways that judges cite similar laws are collected in the hypertext in the links-dataframe.

Assuming that Lovdata’s errors (forgetting to embed law mentions as hypertext) concern laws they at one point in time have embedded as hypertext, we can use the hypertext data to fix Lovdata’s error.

We use the hypertext to generate a dictionary of different ways of citing fundamental rights sources. Some hypertext, however, do not identify which type of FR law that is cited (e.g., the text is simply “article 3”, which can refer to both CRC and EHCR). We remove these entries from the dictionary because they cast a too wide net. Before we remove these entries we need to check whether there are any paragraphs that include these specific string patterns and that is not already cited.

# The dictionary
# BKN
bkn <- unique(links$name[which(str_detect(links$links, "bkn"))])
bkn <- tolower(bkn)
bkn <- str_remove_all(bkn, "\\(")
bkn <- str_remove_all(bkn, "\\)")
bkn <- unique(bkn)
bkn <- bkn[which(str_detect(bkn, "^b"))]
#add manual entries of mentions
bkn <- append(bkn, "barnekomit*")


# SPN
spn <- unique(links$name[which(str_detect(links$links, "spn"))])
spn <- tolower(spn)
spn <- str_remove_all(spn, "\\(")
spn <- str_remove_all(spn, "\\)")
spn <- unique(spn)
spn <- spn[which(str_detect(spn, "^s|^k"))]
spn <- str_replace(spn, "^sp$", "\\bsp\\b")

# ECHR
echr <- unique(links$name[which(str_detect(links$links, "emkn"))])
echr <- tolower(echr)
echr <- str_remove_all(echr, "\\(")
echr <- str_remove_all(echr, "\\)")
echr <- unique(echr)
echr <- str_trim(echr)
echr <- echr[which(str_detect(echr, "^e|^m|^p|^d"))]

# CONSTITUTION
grl <- unique(links$name[which(str_detect(links$links, "1814-05-17"))])
grl <- tolower(grl)
grl <- str_remove_all(grl, "\\(")
grl <- str_remove_all(grl, "\\)")
grl <- unique(grl)
grl <- grl[which(str_detect(grl, "^g"))]

Before we apply the dictionary we make all text lower-case and remove parenthesis.

text_links_summary <- text_links_summary %>%
  mutate(text = tolower(par_text))

text_links_summary <- text_links_summary %>% 
  mutate(text = str_remove_all(text, "\\("))

text_links_summary <- text_links_summary %>% 
  mutate(text = str_remove_all(text, "\\)"))

First, we code paragraphs based on hyperlinks. We create one column for each type of FR law source (e.g. ECHR_in_paragraph), which identify whether that FR law source is cited in the paragraph.

paragraphs_text <-
  text_links_summary %>%
  group_by(case.x, par_paragraph) %>%
  mutate(
    echr_in_paragraph = ifelse(any(
      str_detect(law_name, "European Convention on Human Rights")
    ), "European Convention on Human Rights", NA),
    ecthr_in_paragraph = ifelse(any(str_detect(
      law_name, "ECtHR Caselaw"
    )), "ECtHR Caselaw", NA),
    constitution_in_paragraph = ifelse(any(
      str_detect(law_name, "The Constitution of the Kingdom of Norway")
    ), "The Constitution of the Kingdom of Norway", NA),
    crc_in_paragraph = ifelse(any(
      str_detect(law_name, "Convention on the Rights of the Child")
    ), "Convention on the Rights of the Child", NA),
    iccpr_in_paragraph = ifelse(
      any(
        str_detect(law_name, "International Covenant on Civil and Political Rights")
      ),
      "International Covenant on Civil and Political Rights",
      NA
    ),
    icescr_in_paragraph = ifelse(
      any(
        str_detect(
          law_name,
          "International Covenant on Economic, Social and Cultural Rights"
        )
      ),
      "International Covenant on Economic, Social and Cultural Rights",
      NA
    ),
    un_gc_crc_in_paragraph = ifelse(
      any(
        str_detect(
          law_name,
          "UN General Comment The Committee on the Rights of the Child"
        )
      ),
      "UN General Comment The Committee on the Rights of the Child",
      NA
    ),
    un_gc_ccpr_in_paragraph = ifelse(
      any(
        str_detect(
          law_name,
          "UN General Comment The Committee on Civil and Political Rights"
        )
      ),
      "UN General Comment The Committee on Civil and Political Rights",
      NA
    ),
    un_gc_cescr_in_paragraph = ifelse(
      any(
        str_detect(
          law_name,
          "UN General Comment The Committee on Economic, Social and Cultural Rights"
        )
      ),
      "UN General Comment The Committee on Economic, Social and Cultural Rights",
      NA
    ),
    un_gc_crpd_in_paragraph = ifelse(
      any(
        str_detect(
          law_name,
          "UN General Comment The Committee on the Rights of Persons with Disabilities"
        )
      ),
      "UN General Comment The Committee on the Rights of Persons with Disabilities",
      NA
    ),
    iccpr_caselaw_in_paragraph = ifelse(any(str_detect(
      law_name, "ICCPR Caselaw"
    )), "ICCPR Caselaw", NA),
    cedaw_in_paragraph = ifelse(
      any(
        str_detect(
          law_name,
          "Convention on the Elimination of All Forms of Discrimination against Women"
        )
      ),
      "Convention on the Elimination of All Forms of Discrimination against Women",
      NA
    )
  )

Then we code paragraphs based on hypertext and codebook

paragraphs_text <- paragraphs_text %>%
  distinct(case.x, par_paragraph, .keep_all = T) %>%
  mutate(
    echr_in_paragraph_dict = ifelse(any(str_detect(text, echr)), "European Convention on Human Rights", NA),
    ecthr_in_paragraph_dict = ifelse(any(str_detect(text, "\\bemd\\b")), "ECtHR Caselaw", NA),
    constitution_in_paragraph_dict = ifelse(any(str_detect(text, grl)), "The Constitution of the Kingdom of Norway", NA),
    crc_in_paragraph_dict = ifelse(any(str_detect(text, bkn)), "Convention on the Rights of the Child", NA),
    iccpr_in_paragraph_dict = ifelse(
      any(str_detect(text, spn)),
      "International Covenant on Civil and Political Rights",
      NA
    )
  ) %>%
  ungroup()

Get references from codebook for the coding of overlapping laws

text_links_summary <- text_links_summary %>% 
  mutate(dictionary_references_echr = str_extract_all(text, paste(echr, collapse = "|")),
         dictionary_references_crc = str_extract_all(text, paste(bkn, collapse = "|")),
         dictionary_references_iccpr = str_extract_all(text, paste(spn, collapse = "|")),
         dictionary_references_grl = str_extract_all(text, paste(grl, collapse = "|")))

dictionary_references_echr <- text_links_summary %>% 
  unnest(dictionary_references_echr) %>% 
  select(published, dictionary_references_echr) %>% 
  group_by(published) %>% 
  summarise(laws_echr = str_flatten(dictionary_references_echr, collapse = ", ", na.rm = T))


dictionary_references_crc <- text_links_summary %>% 
  unnest(dictionary_references_crc) %>% 
  select(published, dictionary_references_crc) %>% 
  group_by(published) %>% 
  summarise(laws_crc = str_flatten(dictionary_references_crc, collapse = ", ", na.rm = T))

dictionary_references_iccpr <- text_links_summary %>% 
  unnest(dictionary_references_iccpr) %>% 
  select(published, dictionary_references_iccpr) %>% 
  group_by(published) %>% 
  summarise(laws_iccpr = str_flatten(dictionary_references_iccpr, collapse = ", ", na.rm = T))

dictionary_references_grl <- text_links_summary %>% 
  unnest(dictionary_references_grl) %>% 
  select(published, dictionary_references_grl) %>% 
  group_by(published) %>% 
  summarise(laws_grl = str_flatten(dictionary_references_grl, collapse = ", ", na.rm = T))

# text_links_summary %>% 
#   select(published, article, ditionary_references_echr) %>%
#   unnest(ditionary_references_echr, keep_empty = T) %>%
#   filter(published == "HR-2016-389-A")

# paragraphs_text_ref <- paragraphs_text %>%
#   distinct(case.x, par_paragraph, .keep_all = T) %>%
#   mutate(
#     echr_dict = str_extract_all(text, echr),
#     ecthr_dict = str_extract_all(text, "\\bemd\\b"),
#     constitution_dict = str_extract_all(text, grl),
#     crc_dict = str_extract_all(text, bkn),
#     iccpr_dict = str_extract_all(text, spn)) 

3.4 Law attributes

3.4.1 Number of unique FR laws

We create a variable that counts the number of unique FR laws cited in the decision that we use as a control in the analysis.

# All laws cited in decision

laws <- text_links_summary %>% 
  group_by(case.x, published, section_detailed2) %>%
    summarise(laws = str_flatten(article, collapse = ", ", na.rm = T)) 

# Unique fr laws cited in decision
article_uniqe <- text_links_summary %>% 
  filter(law_name == "European Convention on Human Rights"| law_name ==  "The Constitution of the Kingdom of Norway"| law_name ==  "Convention on the Rights of the Child"| law_name == "International Covenant on Civil and Political Rights") %>% 
  group_by(case.x, article) %>%  
  distinct(case.x, article) %>% 
  group_by(case.x) %>% 
  count() %>% 
  rename(unique_frlaw_articles = n)

3.4.2 Overlapping FR laws per table 2 in manuscript

We create variables that that identify cases with overlapping FR laws and that we use in the analysis shown in figure 4 in the main manuscript

laws_overlap <- text_links_summary %>% 
  filter(law_name == "European Convention on Human Rights"| law_name ==  "The Constitution of the Kingdom of Norway"| law_name ==  "Convention on the Rights of the Child"| law_name == "International Covenant on Civil and Political Rights") %>%
  group_by(case.x, published) %>%
    summarise(laws = str_flatten(article, collapse = ", ", na.rm = T))

laws_overlap <- laws_overlap %>% 
  left_join(dictionary_references_echr, by = "published") %>% 
  left_join(dictionary_references_crc, by = "published") %>% 
  left_join(dictionary_references_iccpr, by = "published") %>% 
  left_join(dictionary_references_grl, by = "published")

Overlap right to privacy

laws_overlap <- laws_overlap %>%
  mutate(
    overlap_privacy = case_when(
      str_detect(laws, "emkn a8") &
        str_detect(laws, "rpost2014_grl102") |
        str_detect(laws, "emkn a8") &
        str_detect(laws, "spn a17") |
        str_detect(laws, "rpost2014_grl102") &
        str_detect(laws, "spn a17") |
        str_detect(laws_echr, "8") & str_detect(laws_iccpr, "17")|
        str_detect(laws_echr, "8") & str_detect(laws_grl, "102")|
        str_detect(laws_grl, "102") & str_detect(laws_iccpr, "17") ~ "Right to privacy"
    )
  )

overlap freedom of expression

laws_overlap <- laws_overlap %>%
  mutate(
    overlap_expression = case_when(
      str_detect(laws, "emkn a10") &
        str_detect(laws, "r_grl100") |
        str_detect(laws, "emkn a10") &
        str_detect(laws, "spn a19") |
        str_detect(laws, "r_grl100") &
        str_detect(laws, "spn a19") |
        str_detect(laws_echr, "10") & str_detect(laws_iccpr, "19")|
        str_detect(laws_echr, "10") & str_detect(laws_grl, "100")|
        str_detect(laws_grl, "100") & str_detect(laws_iccpr, "19") 
        ~ "Freedom of Expression"
    ))

overlap freeom of assembly

laws_overlap <- laws_overlap %>%
  mutate(
    overlap_assembly = case_when(
      str_detect(laws, "emkn a11") &
        str_detect(laws, "rpost2014_grl101") |
        str_detect(laws, "emkn a11") &
        str_detect(laws, "spn a22") |
        str_detect(laws, "rpost2014_grl101") &
        str_detect(laws, "spn a22")| 
        str_detect(laws_echr, "11") & str_detect(laws_iccpr, "22")|
        str_detect(laws_echr, "11") & str_detect(laws_grl, "101")|
        str_detect(laws_grl, "101") & str_detect(laws_iccpr, "22") ~ "Freedom of Assembly"))

overlap childrens rights

laws_overlap <- laws_overlap %>%
  mutate(
    overlap_children = case_when(
      # str_detect(laws, "rpost2014_grl102") &
      #   str_detect(laws, "bkn") |
        str_detect(laws, "rpost2014_grl104") &
        str_detect(laws, "bkn")|
        # !is.na(laws_crc) & str_detect(laws_grl, "102")|
        !is.na(laws_crc) & str_detect(laws_grl, "104") ~ "Children"
    )
  )

overlap physical integrity

laws_overlap <- laws_overlap %>%
  mutate(
    overlap_life = case_when(
      str_detect(laws, "emkn a2") & str_detect(laws, "rpost2014_grl93")|
        str_detect(laws, "emkn a2") & str_detect(laws, "spn a6")|
        str_detect(laws, "rpost2014_grl93") & str_detect(laws, "spn a6")|
        str_detect(laws, "emkn a3") & str_detect(laws, "spn a7") |
        
        str_detect(laws_echr, "emk artikkel 2") & str_detect(laws_iccpr, "artikkel 6")|
        str_detect(laws_echr, "emk artikkel 2") & str_detect(laws_grl, "93")|
        str_detect(laws_grl, "93") & str_detect(laws_iccpr, "artikkel 6")|
        str_detect(laws_echr, "emk artikkel 3") & str_detect(laws_iccpr, "artikkel 7") ~ "Physical integrity"))

overlap liberty

laws_overlap <- laws_overlap %>%
  mutate(
    overlap_liberty = case_when(
      str_detect(laws, "emkn a5") &
        str_detect(laws, "rpost2014_grl94")|
        str_detect(laws, "emkn a5") &
        str_detect(laws, "r_grl99")|
       str_detect(laws, "emkn a5") &
        str_detect(laws, "spn a9")|
         str_detect(laws, "rpost2014_grl94") &
        str_detect(laws, "spn a9")|
        str_detect(laws, "r_grl99") &
        str_detect(laws, "spn a9")|
        str_detect(laws_echr, "5") & str_detect(laws_iccpr, "9")|
        str_detect(laws_echr, "5") & str_detect(laws_grl, "94")|
        str_detect(laws_grl, "94") & str_detect(laws_iccpr, "5") ~ "Liberty"))

overlap fair trail

laws_overlap <- laws_overlap %>%
  mutate(
    overlap_fairtrial = case_when(
      str_detect(laws, "emkn a6") &
        str_detect(laws, "rpost2014_grl95")|
         str_detect(laws, "emkn a6") &
        str_detect(laws, "spn a14")|
        str_detect(laws, "rpost2014_grl95") &
        str_detect(laws, "spn a14")|
        str_detect(laws_echr, "6") & str_detect(laws_iccpr, "14")|
        str_detect(laws_echr, "6") & str_detect(laws_grl, "95")|
        str_detect(laws_grl, "95") & str_detect(laws_iccpr, "14") ~ "Fair trial"))

overlap no punishment witout law

laws_overlap <- laws_overlap %>%
  mutate(
    overlap_nopunishmentwithoutlaw = case_when(
      str_detect(laws, "emkn a7") &
        str_detect(laws, "rpost2014_grl96")|
        str_detect(laws, "emkn a7") &
        str_detect(laws, "rpre2014_grl96")|
         str_detect(laws, "emkn a7") &
        str_detect(laws, "spn a9")|
        str_detect(laws, "rpre2014_grl96") &
        str_detect(laws, "spn a9")|
        str_detect(laws, "rpost2014_grl96") &
        str_detect(laws, "spn a9") ~ "No punishment without law"),
      overlap_nopunishmentwithoutlaw2 = case_when(
        str_detect(laws_echr, "emk artikkel 7") & str_detect(laws_iccpr, "9")|
        str_detect(laws_echr, "emk artikkel 7") & str_detect(laws_grl, "96")|
        str_detect(laws_grl, "96") & str_detect(laws_iccpr, "9") ~ "No punishment without law"))

overlap ex post facto and private property

laws_overlap <- laws_overlap %>%
  mutate(
    overlap_exostfacto_property = case_when(
      str_detect(laws, "emkn p1 a1") & str_detect(laws, "r_grl97")|
        str_detect(laws, "emkn p1 a1") & str_detect(laws, "r_grl105")|
         str_detect(laws_echr, "p1|protokoll 1") & str_detect(laws_grl, "97")|
        str_detect(laws_echr, "p1|protokoll 1") & str_detect(laws_grl, "105") ~ "Ex post facto & property"))

overlap guarantee of equality

laws_overlap <- laws_overlap %>%
  mutate(
    overlap_equality = case_when(
      str_detect(laws, "emkn a14") &
        str_detect(laws, "rpost2014_grl98")|
        str_detect(laws, "emkn a14") &
        str_detect(laws, "spn a26")|
        str_detect(laws, "rpost2014_grl98") &
        str_detect(laws, "spn a26") |
        str_detect(laws_echr, "14") & str_detect(laws_iccpr, "26")|
        str_detect(laws_echr, "14") & str_detect(laws_grl, "98")|
        str_detect(laws_grl, "98") & str_detect(laws_iccpr, "26") ~ "Guarantee of equality"))

overlap culture and language

laws_overlap <- laws_overlap %>%
  mutate(
    overlap_culture = case_when(
      str_detect(laws, "spn a27") &
        str_detect(laws, "rpost2014_grl108") | str_detect(laws_iccpr, "27") & str_detect(laws_grl, "108") 
        ~ "Culture and language"))

overlap freedom of movement

laws_overlap <- laws_overlap %>%
  mutate(
    overlap_freedom_of_movement = case_when(
      str_detect(laws, "emkn p4 a3") &
        str_detect(laws, "rpost2014_grl106")|
        str_detect(laws, "emkn p4 a3") &
        str_detect(laws, "spn a12")|
        str_detect(laws, "rpost2014_grl106") &
        str_detect(laws, "spn a12")|
        str_detect(laws_echr, "protokoll 4 artikkel 3") & str_detect(laws_iccpr, "12")|
        str_detect(laws_echr, "protokoll 4 artikkel 3") & str_detect(laws_grl, "106")|
        str_detect(laws_grl, "106") & str_detect(laws_iccpr, "12")
        
        ~ "Freedom of movement"))

3.4.3 Outcome variables used in analysis

For each relevant FR law, we count the number of paragraphs that cite or mention that specific FR law. The difference between ECHR and ECHR_small is that the former includes references and mentions of ECtHR, while the latter does not.

data <- paragraphs_text %>%
  group_by(case.x, section_detailed2) %>%
  mutate(
    ECHR = sum(
      echr_in_paragraph == "European Convention on Human Rights" |
        ecthr_in_paragraph == "ECtHR Caselaw" |
        echr_in_paragraph_dict == "European Convention on Human Rights" |
        ecthr_in_paragraph_dict == "ECtHR Caselaw",
      na.rm = T
    ),
    ECHR_small = sum(
      echr_in_paragraph == "European Convention on Human Rights" |
        echr_in_paragraph_dict == "European Convention on Human Rights", 
      na.rm = T
    ),
    ECtHR = sum(
        ecthr_in_paragraph == "ECtHR Caselaw" |
        ecthr_in_paragraph_dict == "ECtHR Caselaw",
      na.rm = T
    ),
    CON = sum(
      constitution_in_paragraph == "The Constitution of the Kingdom of Norway" |
        constitution_in_paragraph_dict == "The Constitution of the Kingdom of Norway",
      na.rm = T
    ),
    CRC = sum(
      crc_in_paragraph == "Convention on the Rights of the Child" |
      crc_in_paragraph_dict == "Convention on the Rights of the Child"|
      un_gc_crc_in_paragraph == "UN General Comment The Committee on the Rights of the Child",
      na.rm = T
    ),
    CRC_small = sum(
      crc_in_paragraph == "Convention on the Rights of the Child",
      na.rm = T
    ),
    CRC_caselaw = sum(
      un_gc_crc_in_paragraph == "UN General Comment The Committee on the Rights of the Child",
      na.rm = T
    ),
    ICCPR = sum(
      iccpr_in_paragraph == "International Covenant on Civil and Political Rights" |
        iccpr_caselaw_in_paragraph == "ICCPR Caselaw"|
        un_gc_ccpr_in_paragraph == "UN General Comment The Committee on Civil and Political Rights"|
        iccpr_in_paragraph_dict == "International Covenant on Civil and Political Rights",
      na.rm = T
    ),
    ICCPR_small = sum(
      iccpr_in_paragraph == "International Covenant on Civil and Political Rights" |
        iccpr_in_paragraph_dict == "International Covenant on Civil and Political Rights",
      na.rm = T
    ),
    ICCPR_caselaw = sum(
      iccpr_caselaw_in_paragraph == "ICCPR Caselaw"|
        un_gc_ccpr_in_paragraph == "UN General Comment The Committee on Civil and Political Rights", 
      na.rm = T
    ),
    # fr_law_all = sum(
    #   echr_in_paragraph == "European Convention on Human Rights" |
    #     ecthr_in_paragraph == "ECtHR Caselaw" |
    #     echr_in_paragraph_dict == "European Convention on Human Rights" |
    #     ecthr_in_paragraph_dict == "ECtHR Caselaw" |
    #     constitution_in_paragraph == "The Constitution of the Kingdom of Norway" |
    #     constitution_in_paragraph_dict == "The Constitution of the Kingdom of Norway" |
    #     crc_in_paragraph == "Convention on the Rights of the Child" |
    #     crc_in_paragraph_dict == "Convention on the Rights of the Child" |
    #     un_gc_crc_in_paragraph == "UN General Comment The Committee on the Rights of the Child",
    #     iccpr_in_paragraph == "International Covenant on Civil and Political Rights" |
    #     iccpr_in_paragraph_dict == "International Covenant on Civil and Political Rights"|
    #     iccpr_caselaw_in_paragraph == "ICCPR Caselaw"|
    #     un_gc_ccpr_in_paragraph == "UN General Comment The Committee on Civil and Political Rights"|
    #     un_gc_cescr_in_paragraph == "UN General Comment The Committee on Economic, Social and Cultural Rights"|
    #     un_gc_crpd_in_paragraph == "UN General Comment The Committee on the Rights of Persons with Disabilities"|
    #     cedaw_in_paragraph == "Convention on the Elimination of All Forms of Discrimination against Women"|
    #     icescr_in_paragraph == "International Covenant on Economic, Social and Cultural Rights",
    #   na.rm = T
    # ),
    n_paragraphs = n()
  ) %>%
  distinct(case.x, section_detailed2, .keep_all = T)

3.4.4 FR law mentioned in main question

data <- data %>% 
  group_by(case.x) %>% 
  mutate(
    # frlaw_mainQ = case_when(section_detailed2 == "Main question" & fr_law_all > 0 ~ "FR law in main Q",
    #                              section_detailed2 == "Main question" & fr_law_all == 0 ~ "FR law not in main Q"),
         echr_mainQ = case_when(section_detailed2 == "Main question" & ECHR > 0 ~ "ECHR in main Q",
                                 section_detailed2 == "Main question" & ECHR == 0 ~ "ECHR not in main Q"),
         constitution_mainQ = case_when(section_detailed2 == "Main question" & CON > 0 ~ "CON in main Q",
                                 section_detailed2 == "Main question" & CON == 0 ~ "CON not in main Q"),
         crc_mainQ = case_when(section_detailed2 == "Main question" & CRC > 0 ~ "CRC in main Q",
                                 section_detailed2 == "Main question" & CRC == 0 ~ "CRC not in main Q"),
         iccpr_mainQ = case_when(section_detailed2 == "Main question" & ICCPR > 0 ~ "ICCPR in main Q",
                                 section_detailed2 == "Main question" & ICCPR == 0 ~ "ICCPR not in main Q")  
         ) %>% 
  fill(
    #frlaw_mainQ, 
    echr_mainQ, constitution_mainQ, crc_mainQ, iccpr_mainQ)

Keep the variables we are using

data <- data %>%
  select(
    case.x,
    Dato,
    par_judge,
    par_text,
    section_detailed2,
    ECHR,
    ECHR_small,
    ECtHR, 
    CON,
    CRC,
    CRC_small,
    CRC_caselaw,
    ICCPR,
    ICCPR_small,
    ICCPR_caselaw,
    echr_mainQ, constitution_mainQ, crc_mainQ, iccpr_mainQ,
    n_paragraphs,
    type_of_panel,
    dissent_case,
    type_of_law,
    type_of_decision,
    hr_number,
    rt_number,
    published,
    plenary_impartiality
  )

Merge data with the law attribute-variables

data <- data %>%
  inner_join(laws, by = c("case.x", "section_detailed2"))

data <- data %>%
  inner_join(article_uniqe, by = c("case.x"))

data <- data %>%
  inner_join(laws_overlap, by = c("case.x"))

Pivot data from wide to long

data_long <- data %>%
  pivot_longer(
    cols = c("ECHR", "ECHR_small", "ECtHR",
             "CON", 
             "CRC", "CRC_small", "CRC_caselaw",
             "ICCPR", "ICCPR_small", "ICCPR_caselaw", 
             #"fr_law_all"
             ),
    names_to = "FR_law",
    values_to = "N"
  )

Remove 0’s, keep only opinions (i.e., main opinions, dissenting opinions)

data_long_opinions <- data_long %>%
  filter(N > 0) %>%
  group_by(case.x) %>%
  mutate(fr_law_name = case_when(FR_law == "ECHR" ~ "ECHR",
                                 FR_law == "CON" ~ "CON",
                                 FR_law == "CRC" ~ "CRC",
                                 FR_law == "ICCPR" ~ "ICCPR"), 
    n_fr_laws = n_distinct(fr_law_name, na.rm = T)) %>% 
  filter(section_detailed2 == "Main opinion"| str_detect(section_detailed2, "Dissenting")) %>%
  ungroup()

#Figure 1 in manuscript. Increasing FR law complexity in SCON

#Main dataset

case_data <-  data_long_opinions %>%
  filter(is.na(plenary_impartiality)) %>% 
  group_by(case.x, FR_law) %>%
  mutate(N = sum(N),
         n_paragraphs = sum(n_paragraphs)) %>%
  distinct(case.x, .keep_all = T) %>%
  mutate(prop_para = (N/n_paragraphs)*100)

ANALYSIS

h1_case_data <- case_data %>% 
  mutate(complexity = ifelse(n_fr_laws >1, "Multiple FR laws", "One FR law"),
         complexity = factor(complexity, 
                             levels = c("One FR law", "Multiple FR laws")))

h1_case_data <- h1_case_data %>% 
  mutate(FR_law = factor(FR_law,
                             levels = c("CON", "CRC", "ICCPR", "ECHR")) )
  

# H1

lm1 <- lm(prop_para ~ FR_law, data = h1_case_data)
lm2 <- lm(prop_para ~ FR_law + complexity + type_of_law + type_of_panel + type_of_decision + dissent_case, data = h1_case_data)

#lm2 <- lm(prop_para ~ FR_law*complexity, data = h1_case_data)

fr_predictions <-
  predictions(lm1, type = "response") %>%
  group_by(FR_law) %>%
  summarize(across(c(estimate, conf.low, conf.high), mean)) 

fr_contrast1 <- avg_comparisons(lm1, variables = list(FR_law = "pairwise")) %>%
  mutate(test = case_when(
    contrast == "mean(CRC) - mean(CON)" ~ "H3 UN < CON",
    contrast == "mean(ECHR) - mean(CON)" ~ "H2 ECHR > CON",
    contrast == "mean(ECHR) - mean(CRC)" ~ "H1 ECHR > UN",
    contrast == "mean(ICCPR) - mean(CON)" ~ "H3 UN < CON",
    contrast == "mean(ECHR) - mean(ICCPR)" ~ "H1 ECHR > UN"
  ))

fr_contrast1 <- fr_contrast1 %>%
  mutate(nicelab = case_when(
    contrast == "mean(CRC) - mean(CON)" ~ "CRC - CON",
    contrast == "mean(ECHR) - mean(CON)" ~ "ECHR - CON",
    contrast == "mean(ECHR) - mean(CRC)" ~ "ECHR - CRC",
    contrast == "mean(ICCPR) - mean(CON)" ~ "ICCPR - CON",
    contrast == "mean(ECHR) - mean(ICCPR)" ~ "ECHR - ICCPR"
  ))

fr_contrast1 <- fr_contrast1 %>% 
  filter(!is.na(test))

fr_predictions2 <-
  predictions(lm2, type = "response") %>%
  group_by(FR_law, complexity) %>%
  summarize(across(c(estimate, conf.low, conf.high), mean)) 


fr_contrast2 <- avg_comparisons(lm2, variable = list(FR_law = "pairwise"), by = "complexity") %>% 
  mutate(test = case_when(
    contrast == "mean(CRC) - mean(CON)" ~ "H2c UN < CON",
    contrast == "mean(ECHR) - mean(CON)" ~ "H2b ECHR > CON", 
    contrast == "mean(ECHR) - mean(CRC)" ~ "H2a ECHR > UN",
    contrast == "mean(ICCPR) - mean(CON)" ~ "H2c UN < CON", 
    contrast == "mean(ICCPR) - mean(ECHR)" ~ "H2a UN < ECHR" 
  ),
  contrast = case_when(
    contrast == "mean(CRC) - mean(CON)" ~ "CRC - CON",
    contrast == "mean(ECHR) - mean(CON)" ~ "ECHR - CON", 
    contrast == "mean(ECHR) - mean(CRC)" ~ "ECHR - CRC",
    contrast == "mean(ICCPR) - mean(CON)" ~ "ICCPR - CON", 
    contrast == "mean(ICCPR) - mean(ECHR)" ~ "ICCPR - ECHR" 
  )) %>% 
  filter(!is.na(test))
modelsummary::modelsummary(
list(lm1, lm2), vcov = ~ case.x,
stars = TRUE,
output = "lm.docx")
# frlevels <-
#   ggplot() + geom_point(
#     data = subset(
#       h2_case_data,
#       FR_law == "ECHR" |
#         FR_law == "CON" | FR_law == "CRC" | FR_law == "ICCPR"
#     ),
#     aes(x = FR_law, y = prop_para, colour = FR_law),
#     alpha = 0.7
#   ) +
#   scale_colour_manual(values = c("#CC6666", "#9999CC", "#66CC99", "#E69F00"))
# 
# frlevels <- frlevels +
#   geom_pointrange(data = fr_predictions, aes(x = FR_law, y = estimate, ymin = conf.low, ymax = conf.high), shape = 21, colour = "black", fill = "white",  inherit.aes = FALSE) +
#   #scale_y_continuous(limits = c(0, 1)) +
#   #facet_wrap(~ n_fr_laws) +
#   #coord_flip() +
#   labs(y = "Predicted proportion", x = "Type of FR law") +
#   theme_minimal() +
#   theme(legend.position = "none") 

h1_desc <- 
h1_case_data %>% 
  filter(!is.na(FR_law)) %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.6) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ complexity) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        #plot.title = element_text(face = "bold"),
        #axis.title = element_text(face = "bold"),
        strip.text = element_text(face = "bold"),
        axis.text = element_text(colour = "black",
                             size = 12),
    strip.text.x = element_text(size = 12),
    strip.text.y = element_text(size = 12),
    axis.text.x = element_text(size = 12),
    axis.text.y = element_text(size = 12),
        strip.background = element_rect(fill = "grey80", color = NA))




frcontrasts <- ggplot(fr_contrast1, aes(x = nicelab, y = estimate, ymin = conf.low, ymax = conf.high)) +
  geom_pointrange() +
  geom_hline(yintercept = 0, colour = "grey") +
  #scale_y_continuous(limits = c(0, 0.5)) +
  facet_wrap(~ test, scales = "free_y", ncol = 1) +
  coord_flip() +
  labs(y = "Difference in paragraphs(%)\nengaging with FR laws", x = "") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        #plot.title = element_text(face = "bold"),
        #axis.title = element_text(face = "bold"),
        strip.text = element_text(face = "bold"),
        axis.text = element_text(colour = "black",
                             size = 12),
    strip.text.x = element_text(size = 12),
    strip.text.y = element_text(size = 12),
    axis.text.x = element_text(size = 12),
    axis.text.y = element_text(size = 12),
        strip.background = element_rect(fill = "grey80", color = NA))

median(h1_case_data$prop_para[which(h1_case_data$FR_law == "ECHR")])
## [1] 18.51852
# ECHR
median(h1_case_data$prop_para[which(h1_case_data$FR_law == "ECHR" & h1_case_data$complexity == "One FR law")])
## [1] 18.51852
median(h1_case_data$prop_para[which(h1_case_data$FR_law == "ECHR" & h1_case_data$complexity == "Multiple FR laws")])
## [1] 18.39139
# CON
median(h1_case_data$prop_para[which(h1_case_data$FR_law == "CON" & h1_case_data$complexity == "One FR law")])
## [1] 13.04348
median(h1_case_data$prop_para[which(h1_case_data$FR_law == "CON" & h1_case_data$complexity == "Multiple FR laws")])
## [1] 5.882353
# CON
median(h1_case_data$prop_para[which(h1_case_data$FR_law == "CRC" & h1_case_data$complexity == "One FR law")])
## [1] 18.42105
median(h1_case_data$prop_para[which(h1_case_data$FR_law == "CRC" & h1_case_data$complexity == "Multiple FR laws")])
## [1] 4.819977
# CON
median(h1_case_data$prop_para[which(h1_case_data$FR_law == "ICCPR" & h1_case_data$complexity == "One FR law")])
## [1] 14.28571
median(h1_case_data$prop_para[which(h1_case_data$FR_law == "ICCPR" & h1_case_data$complexity == "Multiple FR laws")])
## [1] 4.188596
median(h1_case_data$prop_para[which(h1_case_data$FR_law == "ECHR" & h1_case_data$complexity == "One FR law")])
## [1] 18.51852

H1 Constituional amendment

H1 Enlarged panel

type_panel <- h1_case_data %>% 
  filter(!is.na(FR_law)) %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 1, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ type_of_panel) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        #plot.title = element_text(face = "bold"),
        #axis.title = element_text(face = "bold"),
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

H1 types of decision

type_decision <- h1_case_data %>% 
  filter(!is.na(FR_law)) %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 1, alpha = 0.7) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.6) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ type_of_decision) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        #plot.title = element_text(face = "bold"),
        #axis.title = element_text(face = "bold"),
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

H1 civil and criminal

type_law <- h1_case_data %>% 
  filter(!is.na(FR_law)) %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 1, alpha = 0.7) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.6) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ type_of_law) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        #plot.title = element_text(face = "bold"),
        #axis.title = element_text(face = "bold"),
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

DISSENT

h1_case_data %>% 
  filter(!is.na(FR_law)) %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 1, alpha = 0.7) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.6) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ dissent_case) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%) engaging with FR laws") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        #plot.title = element_text(face = "bold"),
        #axis.title = element_text(face = "bold"),
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

H1 Overlapping FR laws

1. Right to life

overlap1 <- h1_case_data %>% 
filter(overlap_life == "Physical integrity",
       !is.na(FR_law)) %>%
mutate(panel_label = "Right to Life") %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  #ggrepel::geom_text_repel(min.segment.length = 0, size = 2) +
  facet_wrap (~ panel_label) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        #plot.title = element_text(face = "bold"),
        #axis.title = element_text(face = "bold"),
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

2. Right to liberty

overlap2 <- h1_case_data %>% 
filter(overlap_liberty == "Liberty",
       !is.na(FR_law)) %>%
mutate(panel_label = "Right to Liberty") %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ panel_label) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        axis.text.y=element_blank(), 
        axis.ticks.y=element_blank(), 
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

3. Fair trial

overlap3 <- h1_case_data %>% 
filter(overlap_fairtrial == "Fair trial",
              !is.na(FR_law),
       FR_law != "CRC") %>%
mutate(panel_label = "The Right to a Fair Trial") %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ panel_label) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  labs(x = "", y = "") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        axis.text.y=element_blank(), 
        axis.ticks.y=element_blank(), 
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

4. No punishment without law

overlap4 <- h1_case_data %>% 
filter(overlap_nopunishmentwithoutlaw == "No punishment without law",
       !is.na(FR_law)) %>%
mutate(panel_label = "No Punishment\nWithout Law") %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ panel_label) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        #plot.title = element_text(face = "bold"),
        #axis.title = element_text(face = "bold"),
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

5. General Guarantee of Equality

overlap5 <- h1_case_data %>% 
filter(overlap_equality == "Guarantee of equality",
       !is.na(FR_law)) %>%
mutate(panel_label = "General Guarantee\nof Equality") %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ panel_label) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  labs(x = "", y = "") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        axis.text.y=element_blank(), 
        axis.ticks.y=element_blank(), 
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

6. Freedom of expression

overlap6 <- h1_case_data %>%
filter(overlap_expression == "Freedom of Expression",
       FR_law != "CRC") %>%
  mutate(panel_label = "Freedom of\nExpression") %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ panel_label) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  labs(x = "", y = "") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        axis.text.y=element_blank(), 
        axis.ticks.y=element_blank(), 
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

7. Freedom of Assembly

overlap7 <- h1_case_data %>% 
filter(overlap_assembly == "Freedom of Assembly",
       !is.na(FR_law)) %>%
mutate(panel_label = "Freedom of\nAssembly") %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ panel_label) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        #plot.title = element_text(face = "bold"),
        #axis.title = element_text(face = "bold"),
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

8. Right to privacy

overlap8 <- h1_case_data %>% 
filter(overlap_privacy == "Right to privacy",
       FR_law != "CRC") %>% 
mutate(panel_label = "Right to\nPrivacy") %>%   
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ panel_label) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  labs(x = "", y = "") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        axis.text.y=element_blank(), 
        axis.ticks.y=element_blank(), 
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

9. Children’s rights

overlap9 <- h1_case_data %>% 
filter(overlap_children == "Children", !is.na(FR_law)) %>% 
mutate(panel_label = "Children's\nRights")  %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.7) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ panel_label) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  labs(x = "", y = "") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        axis.text.y=element_blank(), 
        axis.ticks.y=element_blank(), 
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

10. Ex post facto and private property

overlap10 <- h1_case_data %>% 
filter(overlap_exostfacto_property == "Ex post facto & property",
       !is.na(FR_law)) %>%
mutate(panel_label = "Private Property &\nBan on\nEx Post Facto Laws") %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ panel_label) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        #plot.title = element_text(face = "bold"),
        #axis.title = element_text(face = "bold"),
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

11. Freedom of movement

overlap11 <- h1_case_data %>% 
filter(overlap_freedom_of_movement == "Freedom of movement",
       !is.na(FR_law),
       FR_law != "CRC") %>%
mutate(panel_label = "Freedom\nof\nMovement") %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ panel_label) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  labs(x = "", y = "") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        axis.text.y=element_blank(), 
        axis.ticks.y=element_blank(), 
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

12. Right to culture

overlap12 <- h1_case_data %>% 
filter(overlap_culture == "Culture and language",
       !is.na(FR_law),
       FR_law != "CRC") %>%
mutate(panel_label = "Right\nto\nCulture") %>% 
ggplot(aes(x = FR_law, y = prop_para)) +
  geom_half_point(aes(color = FR_law), 
                  transformation = position_quasirandom(width = 0.1),
                  side = "l", size = 2, alpha = 0.6) +
  geom_half_boxplot(aes(fill = FR_law), side = "r", alpha = 0.7) + 
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ panel_label) +
  #coord_flip() +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%)\nengaging with FR laws") +
  theme_minimal() +
  labs(x = "", y = "") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        axis.text.y=element_blank(), 
        axis.ticks.y=element_blank(), 
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))

Overlap figure

MAIN QUESTION IN THE CASE

h1_case_data %>%
  filter(!is.na(FR_law), echr_mainQ == "ECHR in main Q" & constitution_mainQ == "CON in main Q") %>% 
  filter(FR_law == "ECHR"| FR_law == "CON") %>% 
  mutate(name ="ECHR and Constitution in main question",
         label_panel = paste(published, 
                             str_replace_all(type_of_panel, " panel", ""), 
                             overlap_privacy, 
                             overlap_children, 
                             overlap_fairtrial,
                             overlap_exostfacto_property, 
                             overlap_expression,
                             overlap_assembly, 
                             overlap_nopunishmentwithoutlaw,
                             sep = ", "),
         label_panel = str_replace_all(label_panel, "NA,|, NA", ""),
         label_panel = str_replace_all(label_panel, ", ", "\n"),
         label_panel = str_replace_all(label_panel, "Rt-2011-347\nFive-judge", "Rt-2011-347\nFive-judge\nEx post facto & No punishment without law"),
         label_panel = str_replace_all(label_panel, "HR-2018-1783-A\nFive-judge", "HR-2018-1783-A\nFive-judge\nPresumption of innocence")) %>%
  ggplot(aes(x = FR_law, y = prop_para)) +
  geom_col(aes(color = FR_law, fill = FR_law)
           ) +
  scale_y_continuous(limits = c(0, 100)) +
  scale_fill_viridis_d(option = "plasma", end = 0.8) +
  scale_color_viridis_d(option = "plasma", end = 0.8) +
  scale_x_discrete(labels = label_wrap(10)) +
  facet_wrap (~ reorder(str_wrap(label_panel, 13), date(Dato))) +
  guides(color = "none", fill = "none") +
  labs(x = "", y = "Paragraphs(%) engaging with FR laws") +
  theme_minimal() +
  theme(panel.grid.minor = element_blank(),
        plot.background = element_rect(fill = "white", color = NA),
        strip.text = element_text(face = "bold"),
        strip.background = element_rect(fill = "grey80", color = NA))