简体   繁体   中英

How to add a css file to R Shiny to improve my app?

I have attempted to build a Shiny R. I have succeed with stack overflow member. Yet, been encouraged to add more questions as on their own. I have several issues with my app:

  1. As you can see, my map does not occupy the entire screen. Is it possible to get that? How? (I have updated the question with this additional point)

Here is what I have managed to achieve:

library(shiny)
library(tidyverse)
library(leaflet)

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(
    
    # Application title
    h1("Symptoms accross the world"),
    
    # Sidebar with a slider input for number of bins 
    leafletOutput("map"), 
    
    #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",
                  
                  shiny::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"), multiple = TRUE)
                  
    )
    
)

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)

I have solved first issue with with this code:

leafletOutput("map", width = "100%", height = "95vh")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM