(function(packages) {for (pack in packages) {
  tryCatch({library(pack,character.only = TRUE)},
           error = function(e){install.packages(pack)
                               library(pack, character.only = TRUE)})}}) -> package_installer
#Packages go here
c("rvest", "readtext", "webdriver", "tidyverse", "flextable", "webdriver", "tidytext", "twitteR", "ggplot2", "dplyr", "magrittr", "shiny", "shinyWidgets") -> packages 
package_installer(packages)
## ── 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.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter()         masks stats::filter()
## ✖ readr::guess_encoding() masks rvest::guess_encoding()
## ✖ dplyr::lag()            masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## 
## Attaching package: 'flextable'
## 
## 
## The following object is masked from 'package:purrr':
## 
##     compose
## 
## 
## 
## Attaching package: 'twitteR'
## 
## 
## The following objects are masked from 'package:dplyr':
## 
##     id, location
## 
## 
## 
## Attaching package: 'magrittr'
## 
## 
## The following object is masked from 'package:purrr':
## 
##     set_names
## 
## 
## The following object is masked from 'package:tidyr':
## 
##     extract
read.csv("links.csv") -> bbc_headline_links

# Define UI
ui <- fluidPage(
  titlePanel("Headlines Table"),
  dataTableOutput("headlines_table")
)

# Define server logic
server <- function(input, output, session) {
  # Render the data table
  output$headlines_table <- renderDataTable({
    # Create links for each URL
    sapply(bbc_headline_links$Link, function(url) {
      a("Link", href = url, target = "_blank")
    }) -> bbc_headline_links$Link
    # Return the data table
    datatable(bbc_headline_links, options = list(pageLength = 5), escape = FALSE) -> dt
    dt
  })
}

# Run the application
shinyApp(ui = ui, server = server)
Shiny applications not supported in static R Markdown documents