Skip to content

Commit

Permalink
Key scripts for Table 7.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoGarcezAurelio committed Aug 26, 2024
1 parent 40e2d3a commit e87828f
Show file tree
Hide file tree
Showing 356 changed files with 807,239 additions and 0 deletions.
108 changes: 108 additions & 0 deletions app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
source("data_cleaning.R")

thematic_shiny()

ui <- page_fluid(
theme = bs_theme(preset = "minty"),
headerPanel("Table 7 - The association between quality of delivery and outcomes as reported across studies (N = 10)"),
reactableOutput("Table7"),
textInput("footnote", "* indicates a negative association; ** indicates a significant interaction; *** ES calculated by research team when not reported in paper using ES calculator psychometrica.de",
width = "100%"))

server <- function(input, output) {
output$Table7 <- renderReactable({
reactable(Table7,
theme = default(centered = TRUE),
filterable = TRUE,
bordered = FALSE,
striped = FALSE,
highlight = TRUE,
searchable = TRUE,
defaultPageSize = 16,
groupBy = "Outcome Domain",
columns = list(
Study_ID = colDef(
align = "center",
maxWidth = 130,
name = "Study ID",
cell = function(value, index) {
label4 <- DOITable7[index, "Study_ID"] # had to create a separate file for the DOIs for this table and just replaced label1 with label3 in case there was the risk of some overwriting. Same for DOI3 below
DOI4 <- DOITable7[index, "DOI"]
htmltools::div(
htmltools::p(
htmltools::tags$a(href = DOI4, target = "_blank", label4)
),
)
}
),
"First Author" = colDef(
align = "left",
maxWidth = 130
),
Year = colDef(
align = "center",
maxWidth = 130
),
Country = colDef(
header = with_tooltip("Country",
"Country where data was collected"),
maxWidth = 130
),
CountryFlag = colDef(
name = "",
maxWidth = 70,
align = "center",
cell = embed_img("Country",
height = "25",
width = "40")
),
"Outcome Domain" = colDef(
align = "center",
header = with_tooltip("Outcome Domain",
"Student outcome(s) assessed"),
),
"Classification" = colDef(
header = with_tooltip("Classification", "Classification Quality"),
align = "center",
maxWidth = 120,
cell = pill_buttons(Table7,
color_ref = "Classification_colours",
opacity = 0.7),
),
"Classification_colours" = colDef(
show = FALSE),
"Total Tests" = colDef(
align = "center",
header = with_tooltip(
"Total Tests",
"Total of statistical tests performed"),
cell = data_bars(Table7,
text_position = "center",
round_edges = TRUE,
box_shadow = TRUE,
bar_height = 15)),
"Statistically Significant Tests" = colDef(
align = "center",
maxWidth = 190,
header = with_tooltip(
"Statistically Significant Tests",
"Total of statistically significant tests"),
cell = data_bars(Table7,
text_position = "center",
round_edges = TRUE,
box_shadow = TRUE,
bar_height = 15)),
"Effect Size" = colDef(
align = "center",
header = with_tooltip(
"Effect Size",
"Effect Sizes and their range, where applicable, for statistically significant effects")
)
)
)
})

}

# Run the application
shinyApp(ui = ui, server = server)
89 changes: 89 additions & 0 deletions data_cleaning.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Key packages for the app

# install.packages("shiny") # For the shiny app
# install.packages("bslib") # For certain shiny app traits
# install.packages("readr") # For loading csv
# install.packages("shinythemes") # For shiny themes
# install.packages("thematic") # For consistence between layout and plots
# install.packages("reactable") # For table
# install.packages("reactablefmtr") # For table
# install.packages("here") # For file management
# install.packages("shinylive") # For github optimisation
# install.packages("htmltools") # For the DOI links
# install.packages("magrittr") # For the pipe (avoided tidyverse in case it makes it more difficult for shinyserver)
# install.packages("dplyr") # For the mutate functions

# Loading the packages

library(shiny)
library(bslib)
library(readr)
library(shinythemes)
library(thematic)
library(reactable)
library(reactablefmtr)
library(here)
library(shinylive)
library(htmltools)
library(magrittr)
library(dplyr)


# Uploading the table

Table7 <-
read_csv(here("Data",
"Processed Data",
"Table7.csv"))

# Now I create the colour code I want the classification variable to have:

Table7 <- Table7 %>%
mutate(
Classification_colours = case_when(Classification == "High" ~ "darkgreen",
Classification == "Low" ~ "red",
TRUE ~ "orange")
)

# Creating a tooltip option that will be used in the headers.

with_tooltip <- function(value, tooltip) {
tags$abbr(style = "text-decoration: underline; text-decoration-style: dotted; cursor: help",
title = tooltip, value)
}


# I will need a different DOI table for Table 6:

DOITable7 <- data.frame(
Study_ID = c("13", "16", "10", "12", "17", "23", "29", "4", "10", "10", "29",
"16", "8", "10", "17", "29","13","16","4","8","10","12","17","29",
"13", "4", "11", "29"),
DOI = c("Not available",
"https://doi.org/10.1002/ajcp.12092",
"https://doi.org/10.1080/02796015.2007.12087949",
"https://doi.org/10.1007/s11121-017-0802-4",
"https://doi.org/10.1007/s11121-018-0948-8",
"https://doi.org/10.1080/02796015.2012.12087377",
"https://doi.org/10.3310/phr06100",
"https://doi.org/10.1037//0022-006x.67.5.648",
"https://doi.org/10.1080/02796015.2007.12087949",
"https://doi.org/10.1080/02796015.2007.12087949",
"https://doi.org/10.3310/phr06100",
"https://doi.org/10.1002/ajcp.12092",
"http://dx.doi.org/10.1016/j.jsp.2014.07.001",
"https://doi.org/10.1080/02796015.2007.12087949",
"https://doi.org/10.1007/s11121-018-0948-8",
"https://doi.org/10.3310/phr06100",
"Not available",
"https://doi.org/10.1002/ajcp.12092",
"https://doi.org/10.1037//0022-006x.67.5.648",
"http://dx.doi.org/10.1016/j.jsp.2014.07.001",
"https://doi.org/10.1080/02796015.2007.12087949",
"https://doi.org/10.1007/s11121-017-0802-4",
"https://doi.org/10.1007/s11121-018-0948-8",
"https://doi.org/10.3310/phr06100",
"Not available",
"https://doi.org/10.1037//0022-006x.67.5.648",
"https://doi.org/10.1186/isrctn85087674",
"https://doi.org/10.3310/phr06100"))
Loading

0 comments on commit e87828f

Please sign in to comment.