Greek sites

misc
Author
Published

Tuesday, 17 September 2024

Figure 1: Greek sites
library(tidyverse)
library(shiny)
library(sf)
library(leaflet)

# https://www.usit.uio.no/om/organisasjon/ffu/dht/aktiviteter/task/task-bloggen/rtv-map-tool.html

# tap <- title_list %>%
#   # filter(first_date_held > input$years[1] & first_date_held < input$years[2]) %>%
#   # count(coverage_city, name = 'titles') %>%
#   left_join(coordinates_list, by = 'coverage_city')%>%
#   filter(!is.na(lng) & !is.na(lat)) %>%
#   st_as_sf(coords = c('lng', 'lat')) %>%
#   st_set_crs(2100)


setwd("~/Documents/webpages/michaelczeller.github.io/blog/2024/09/17/greece/greek_tester")

title_list = read_csv('BritishAndIrishNewspapersTitleList_20191118.csv')
Rows: 13 Columns: 26
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (9): place_of_publication, country_of_publication, general_area_of_cove...
dbl  (4): title_id, free_text_information_about_dates_of_publication, lat, lng
lgl (13): nid, nlp, publication_title, edition, preceding_titles, succeeding...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
title_list$first_date_held <- as.numeric(title_list$first_date_held)
title_list$last_date_held <- as.numeric(title_list$last_date_held)

# coordinates_list = read_csv('newspaper_coordinates.csv')

ui = fluidPage(

  titlePanel("Greek Map"),

  sidebarLayout(

    sidebarPanel = sidebarPanel(sliderInput('years', 'Years', min = 20, max = 1493, value = c(1, 1000))),
    mainPanel = mainPanel(

      leafletOutput(outputId = 'map')

    )
  )

)
Warning: In sliderInput(): `value` should be greater than or equal to `min`
(value = 1, 1000, min = 20).
server = function(input, output){

  map_df = reactive({

    title_list %>%
      filter(first_date_held > input$years[1] & first_date_held < input$years[2]) %>%
      # count(coverage_city, name = 'titles') %>%
      # left_join(coordinates_list, by = 'coverage_city')%>%
      filter(!is.na(lng) & !is.na(lat)) %>%
      st_as_sf(coords = c('lng', 'lat')) %>%
      st_set_crs(2100)

  })

  output$map = renderLeaflet({

    leaflet() %>%
      addTiles() %>%
      setView(lng = 25.5, lat = 38.5, zoom = 6) %>%
      addCircleMarkers(data = title_list,
                       lng = ~lng, lat = ~lat,
                       popup = paste("Place:", title_list$place_of_publication,
                                     "<br>", "God:", title_list$publisher, 
                                     "<br>", "Poem:",
                                     '<a href=', title_list$explore_link, '>', "Click here",
                                     '</a>'))
                       # , radius = ~sqrt(titles))

  })


}

shinyApp(ui, server)
PhantomJS not found. You can install it with webshot::install_phantomjs(). If it is installed, please make sure the phantomjs executable can be found via the PATH variable.

Shiny applications not supported in static R Markdown documents