I am attempting to incorporate my css file into Shiny R. I have been able to run the application without any issues before adding the style.css file. Below are the steps I have taken:
library(shiny)
library(tidyverse)
library(leaflet)
library(leaflet.extras)
fake_data <- read.csv("https://raw.githubusercontent.com/gabrielburcea/stackoverflow_fake_data/master/gather_divided.csv")
# Define UI for application that draws a histogram
ui <- fluidPage(
navbarPage("SARS-Covid-19 Symptom Mapper",
div(class = "outer",
tabPanel("Interactive map",
div(class = "outer",
tags$head(
# Include our custom CSS
includeCSS("style.css")
),
leafletOutput("map", width = "100%", height = "95vh"),
#Floating panel
absolutePanel(id = "controls", class = "panel panel-default", fixed = TRUE,
draggable = TRUE, top = 60, left = "auto", right = 20, bottom = "auto",
width = 330, height = "auto",
h2("Select symptom"),
selectInput("symptom", "Select Symptom", c("Chills",
"Cough", "Diarrhoea",
"Fatigue",
"Headache",
"Loss of smell and taste",
"Muscle ache",
"Nasal congestion",
"Nausea and vomiting",
"Shortness of breath",
"Sore throat",
"Sputum",
"Temperature")
)
)
)
server <- function(input, output) {
filtered_data <- reactive({
fake_data %>%
dplyr::filter(Symptom %in% input$symptom)
})
output$map <- renderLeaflet({
leaflet() %>%
addTiles() %>%
addMarkers(data = filtered_data(), clusterOptions = markerClusterOptions())
})
}
# Run the application
shinyApp(ui = ui, server = server)
The error I encounter is:
Error in parse(file, keep.source = FALSE, srcfile = src, encoding = enc) :
/Users/myname/Rprojects/training_shiny/app.R:53:1: unexpected symbol
52:
53: server
However, if I exclude working with css, the app runs smoothly without any issues. Specifically, if I remove the lines from navbarPage all the way to line leafletOutput, leaving the code from leafletOutput onwards, the app runs without errors. The difficulty arises when trying to implement the style.css file. For more information on how I ran the app without css, refer to this link: integrating leaflet map in RShiny - inputselect by country and symptom