Systematic Paper

Author

Ellelouise

Published

November 15, 2024

── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Attaching package: 'gplots'


The following object is masked from 'package:stats':

    lowess


Loading required package: grid

corrplot 0.95 loaded

Linking to GEOS 3.13.0, GDAL 3.8.5, PROJ 9.5.1; sf_use_s2() is TRUE

Loading required package: viridisLite
data <- read_excel("Book1.xlsx", sheet = 1)

# Summarize the number of studies per year
study_counts <- data %>%
  group_by(Year) %>%
  summarise(Num_Studies = n()) %>%
  arrange(Year)

# Define custom colors (no trailing comma)
colors <- c(
  "2000" = "#00f9ff",
  "2003" = "#00f9ff",
  "2004" = "#009fff",
  "2005" = "#00f9ff",
  "2006" = "#00f9ff",
  "2008" = "#00f9ff",
  "2009" = "#00f9ff",
  "2011" = "#0051ff",
  "2012" = "#00f9ff",
  "2014" = "#009fff",
  "2016" = "#00f9ff",
  "2017" = "#009fff",
  "2022" = "#00f9ff",
  "2024" = "#009fff",
  "2025" = "#00f9ff"
)

# Add `fill = as.factor(Year)` so ggplot knows to use colors
ggplot(
  study_counts %>% filter(Year >= 2000, Year <= 2025),
  aes(x = Year, y = Num_Studies, fill = as.factor(Year))
) +
  geom_bar(stat = "identity", color = "black", alpha = 0.8) +
  scale_fill_manual(values = colors, na.value = "grey") +
  labs(
    title = "Number of Studies Published (2000–2025)",
    x = "Year",
    y = "Number of Studies (count)"
  ) +
  theme_minimal() +
  scale_x_continuous(breaks = seq(2000, 2025, by = 1)) +
  theme(
    axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1),
    legend.position = "none",
    axis.title.x = element_text(margin = margin(t = 10)) 
  )

install.packages("htmlwidgets", repos = "https://cran.rstudio.com/")

The downloaded binary packages are in
    /var/folders/_3/72qxm8d92yvbjb7qytpw9kg80000gn/T//Rtmp4n6q40/downloaded_packages
library(htmlwidgets)
library(dplyr)
library(plotly)

Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':

    last_plot
The following object is masked from 'package:stats':

    filter
The following object is masked from 'package:graphics':

    layout
# 1. Define the custom color scale
# The list format is: [[stop_position (0 to 1), "color_code"]]
custom_blue_scale <- list(
  list(0.0, '#00f9ff'), # Lightest blue for the lowest count
  list(0.5, '#009fff'), # Mid-blue for intermediate counts
  list(1.0, '#0051ff')  # Deep navy for the highest count
)

# 2. Data creation and cleaning
country_data <- c(
  rep("United States", 6),
  rep("United Kingdom", 4),
  rep("China", 3),
  rep("Iran", 3),
  "Korea",
  "Poland",
  "Turkey",
  "Germany",
  "Russia",
  "Ukraine"
)

publications <- data.frame(Country_of_Publication = country_data)

country_counts <- publications %>%
  group_by(Country_of_Publication) %>%
  summarise(Count = n()) %>%
  arrange(desc(Count))

# 3. CRITICAL FIX: Standardize Country Names for Map Compatibility
# The plotly map database requires specific names for some countries.
country_counts_fixed <- country_counts %>%
  mutate(
    Country_of_Publication = case_when(
      Country_of_Publication == "United States" ~ "USA",
      Country_of_Publication == "Korea" ~ "South Korea",
      Country_of_Publication == "Russia" ~ "Russian Federation",
      Country_of_Publication == "Iran" ~ "Iran (Islamic Republic of)",
      .default = Country_of_Publication
    )
  )

# 4. Create the interactive choropleth map
fig <- plot_ly(
    type = 'choropleth',
    locations = country_counts_fixed$Country_of_Publication, # Use the fixed names
    locationmode = 'country names',
    z = country_counts_fixed$Count,
    text = paste(country_counts_fixed$Country_of_Publication, "<br>Count: ", country_counts_fixed$Count), # Custom hover text
    colorscale = custom_blue_scale,
    marker = list(line = list(color = 'white', width = 0.5)),
    colorbar = list(title = 'Publication Count')
  ) %>%
  # Use plotly::layout() for map projection and title settings
  plotly::layout(
    title = 'Publication Count by Country (Interactive Map)',
    geo = list(
      scope = 'world',
      projection = list(type = 'natural earth'),
      showland = TRUE,
      landcolor = 'lightgrey' 
    )
  )

# 5. Display the map (This is the critical final step)
htmlwidgets::saveWidget(
  widget = fig,
  file = "publication_map_final.html",
  selfcontained = TRUE
)