---
title: "Radiographic Analysis"
author: "Sergio Uribe"
date-modified: last-modified
format:
html:
toc: true
toc-expand: 3
code-fold: true
code-tools: true
editor: visual
execute:
echo: false
cache: false
warning: false
message: false
---
# Packages
```{r}
pacman::p_load(tidyverse, # tools for data science
visdat, #NAs
janitor, # for data cleaning and tables
here, # for reproducible research
gtsummary, # for tables
countrycode, # to normalize country data
easystats, # check https://easystats.github.io/easystats/
scales,
irr, # for agreement
lubridate
)
# FOR EDA try DataExplorer, SmartEDA o dllokr, check https://www.youtube.com/watch?v=sKrWYE63Vk4&t=7s
```
# Dataset
## Pilot study
```{r}
pilot <- read_csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vTCbgTOL0YgSx4EcW1chWabNEGqNMPIPwClKKIYpIJx5Z1XHi9jh_E9CtKAnlL5NfopYGb6TlZz0v_d/pub?gid=1052330035&single=true&output=csv")
```
##
Store a copy
```{r}
# write_rds(pilot, here("data_miks_2024", "pilot.rds"))
```
# Agreement
### Root development
```{r}
# Filter and select the relevant columns
pilot |>
select(Evaluator, `Radiograph #`, `Root development`) |>
mutate(`Root development` = case_when(
`Root development` == "+" ~ "Yes",
TRUE ~ "No"
)) |>
arrange(desc(`Radiograph #`)) |>
mutate(`Radiograph #` = str_trim(`Radiograph #`, side = c("both"))) |>
pivot_wider(names_from = Evaluator,
values_from = `Root development`) |>
select(Neimane, Uribe) %>%
drop_na() %>%
{ irr::kappa2(.) } # Pass the dataframe directly as the first argument
```
### Obliteration
```{r}
pilot %>%
select(Evaluator, `Radiograph #`, Obliteration) %>%
arrange(desc(`Radiograph #`)) %>%
mutate(`Radiograph #` = str_trim(`Radiograph #`, side = "both")) %>%
pivot_wider(names_from = Evaluator, values_from = Obliteration) %>%
select(Neimane, Uribe) %>%
drop_na() %>%
{ irr::kappa2(.) }
```
### Periapical status
```{r}
pilot %>%
select(Evaluator, `Radiograph #`, `Periapical status` ) %>%
arrange(desc(`Radiograph #`)) %>%
mutate(`Radiograph #` = str_trim(`Radiograph #`, side = "both")) %>%
pivot_wider(names_from = Evaluator, values_from = `Periapical status`) %>%
select(Neimane, Uribe) %>%
drop_na() %>%
{ irr::kappa2(.) }
```
### Crown Final
```{r}
pilot %>%
select(Evaluator, `Radiograph #`, `Crown FINAL (in pixels)`) %>%
arrange(desc(`Radiograph #`)) %>%
mutate(`Radiograph #` = str_trim(`Radiograph #`, side = "both")) %>%
pivot_wider(names_from = Evaluator, values_from = `Crown FINAL (in pixels)`) %>%
select(Neimane, Uribe) %>%
drop_na() %>%
{ irr::icc(.) }
```
```{r}
rm(pilot)
```