0

Below is sample of a dataset I'm using to build a shiny app. Everything works, I just need some guidance in laying out some of the pages.

df<-df<-structure(list(lon = c(-1.309306062, -1.308591288, -1.308725397, 
-1.308223849, -1.309100942, -1.308788844, -1.309505208, -1.309487017, 
-1.307965425, -1.307626664, -1.309264223, -1.306229451, -1.307167439, 
-1.307846954, -1.308361108, -1.309967322, -1.310144073, -1.310207229, 
-1.310332327, -1.310671738, -1.31180421, -1.311607541, -1.312474199, 
-1.312743518, -1.313056542, -1.312181745, -1.311154382, -1.311484218, 
-1.310989254, -1.312408125, -1.312799476, -1.313737475, -1.314102982, 
-1.313547026, -1.313998781, -1.313728937, -1.313688331, -1.313176409, 
-1.312907533, -1.312342883, -1.31196085, -1.309571159, -1.310019078, 
-1.309446474, -1.310651343, -1.311742706, -1.312701894, -1.313373501, 
-1.312104413, -1.311081217, -1.309651304, -1.309355735, -1.308883116, 
-1.309512252, -1.308505874, -1.307611868, -1.308034561, -1.308878841, 
-1.30959055, -1.306611007, -1.310526938, -1.310785205, -1.31160273, 
-1.311550922, -1.311502941, -1.310709008, -1.309426224, -1.306562029, 
-1.31304945, -1.312303923, -1.309432075, -1.308759213, -1.308113121, 
-1.30921558, -1.30698489, -1.307679453, -1.307993641, -1.308824096, 
-1.309891996, -1.310095431, -1.310615541, -1.31084027, -1.310663799, 
-1.310396993, -1.311282331, -1.312165532, -1.312140463, -1.312682769, 
-1.311926141, -1.311824037, -1.312745885, -1.313058922, -1.313732569, 
-1.314639773, -1.313463089, -1.31279367, -1.308839997, -1.312446898, 
-1.310518884, -1.312237405, -1.313899224, -1.309127168, -1.314035676, 
-1.311071515, -1.31028724, -1.309057883, -1.306676951, -1.307564253, 
-1.30714901, -1.308095356, -1.307645637, -1.307967975, -1.307768975, 
-1.329996387, -1.332834197, -1.330372664, -1.33032833, -1.331746318, 
-1.331257985, -1.333494628, -1.331850567, -1.332551665, -1.331679116, 
-1.331287582, -1.330303341, -1.329878063, -1.329108814, -1.328358002, 
-1.328655294, -1.328379776, -1.328319218, -1.328879225), lat = c(51.76457202, 
51.76488251, 51.76464054, 51.76370376, 51.76375109, 51.76428126, 
51.76481595, 51.76505861, 51.76601172, 51.76636938, 51.76544329, 
51.76676575, 51.76702303, 51.76712594, 51.76667041, 51.76587064, 
51.76568286, 51.76534201, 51.76473989, 51.76433727, 51.76419105, 
51.76365969, 51.76351641, 51.76340532, 51.76378478, 51.76413932, 
51.76499646, 51.76522317, 51.76537312, 51.76545336, 51.76544665, 
51.76570388, 51.76549023, 51.76488457, 51.76471637, 51.76435515, 
51.7641661, 51.76352474, 51.76310058, 51.7630703, 51.76341873, 
51.76334178, 51.76342533, 51.76391649, 51.76567684, 51.7663306, 
51.7661474, 51.76677171, 51.76732175, 51.76790019, 51.76853917, 
51.76891506, 51.76949672, 51.7691048, 51.7685774, 51.76828442, 
51.76812506, 51.76787827, 51.76682149, 51.76645331, 51.76623357, 
51.76354671, 51.7660061, 51.76655426, 51.76685069, 51.76664823, 
51.76714421, 51.76681267, 51.76425228, 51.76277337, 51.76771069, 
51.76812033, 51.76867399, 51.76955262, 51.7675884, 51.76765543, 
51.76700991, 51.76671809, 51.76605901, 51.76507117, 51.76517312, 
51.76468892, 51.76485872, 51.7642997, 51.76420598, 51.76368993, 
51.76399521, 51.76405674, 51.76474922, 51.76574665, 51.76515862, 
51.76553808, 51.76602754, 51.7654484, 51.76468628, 51.76296504, 
51.76377806, 51.76290008, 51.76581093, 51.76619863, 51.76650504, 
51.76395058, 51.76706329, 51.76758544, 51.7686508, 51.76849073, 
51.76593221, 51.76571265, 51.76538652, 51.76509539, 51.7651287, 
51.76489683, 51.7646439, 51.75921563, 51.75639953, 51.75924475, 
51.75892126, 51.75708613, 51.75667003, 51.75680788, 51.75629504, 
51.75689245, 51.75613223, 51.75615698, 51.75598657, 51.75605949, 
51.75615401, 51.75695893, 51.75742817, 51.75744458, 51.75800124, 
51.75795993), nestbox = c("B10", "B100", "B101", "B104", "B107", 
"B109", "B11", "B111", "B116", "B118", "B12", "B121", "B122", 
"B123", "B125", "B129", "B130", "B131", "B133", "B136", "B138", 
"B139", "B140", "B141", "B142", "B147", "B149", "B150", "B151", 
"B153", "B157", "B160", "B161", "B163", "B164", "B165", "B166", 
"B168", "B169", "B170A", "B171", "B173", "B174", "B175", "B176", 
"B177", "B178", "B180", "B183", "B185", "B188", "B189", "B190", 
"B191", "B193", "B194", "B194A", "B195", "B197", "B20", "B200", 
"B203", "B211", "B213", "B214", "B216", "B217", "B22", "B220", 
"B221", "B224", "B225", "B226", "B227", "B228", "B23", "B24", 
"B26", "B29", "B31", "B32", "B33", "B35", "B36", "B37", "B40", 
"B43", "B44", "B49", "B53", "B57", "B58", "B60", "B62A", "B65", 
"B69", "B7", "B70", "B76", "B78", "B79", "B8", "B80A", "B85", 
"B88", "B89", "B93", "B95", "B96", "B97", "B98", "B99", "B99A", 
"C1", "C10", "C101", "C102", "C107", "C108", "C109", "C11", "C110", 
"C111", "C112", "C114", "C115", "C116", "C118", "C120", "C122", 
"C123", "C124"), Species = c("Blue tit", "Blue tit", "Great tit", 
"Great tit", "Blue tit", "Blue tit", "Blue tit", "Blue tit", 
"Great tit", "Great tit", "Blue tit", "Blue tit", "Blue tit", 
"Blue tit", "Blue tit", "Great tit", "Blue tit", "Blue tit", 
"Blue tit", "Blue tit", "Blue tit", "Blue tit", "Blue tit", "Blue tit", 
"Blue tit", "Blue tit", "Blue tit", "Great tit", "Blue tit", 
"Blue tit", "Blue tit", "Blue tit", "Blue tit", "Great tit", 
"Blue tit", "Blue tit", "Nuthatch", "Blue tit", "Great tit", 
"Blue tit", "Great tit", "Blue tit", "Blue tit", "Great tit", 
"Blue tit", "Blue tit", "Blue tit", "Blue tit", "Blue tit", "Blue tit", 
"Great tit", "Blue tit", "Blue tit", "Blue tit", "Great tit", 
"Blue tit", "Great tit", "Marsh tit", "Blue tit", "Great tit", 
"Great tit", "Great tit", "Blue tit", "Great tit", "Blue tit", 
"Great tit", "Great tit", "Blue tit", "Blue tit", "Blue tit", 
"Great tit", "Blue tit", "Blue tit", "Blue tit", "Blue tit", 
"Blue tit", "Great tit", "Blue tit", "Blue tit", "Great tit", 
"Great tit", "Blue tit", "Great tit", "Great tit", "Blue tit", 
"Blue tit", "Great tit", "Great tit", "Great tit", "Blue tit", 
"Great tit", "Great tit", "Blue tit", "Blue tit", "Great tit", 
"Blue tit", "Blue tit", "Blue tit", "Great tit", "Great tit", 
"Great tit", "Great tit", "Blue tit", "Blue tit", "Blue tit", 
"Blue tit", "Blue tit", "Blue tit", "Blue tit", "Blue tit", "Great tit", 
"Blue tit", "Blue tit", "Blue tit", "Great tit", "Blue tit", 
"Blue tit", "Great tit", "Great tit", "Great tit", "Great tit", 
"Blue tit", "Blue tit", "Great tit", "Blue tit", "Great tit", 
"Blue tit", "Great tit", "Blue tit", "Blue tit", "Blue tit", 
"Great tit"), Clutch.size = c(9L, 10L, 9L, 6L, 10L, 10L, 10L, 
9L, 7L, 8L, 9L, 9L, 10L, 8L, 10L, 10L, 9L, 8L, 8L, 8L, 8L, 9L, 
10L, 7L, 11L, 10L, 11L, 6L, 6L, 9L, 8L, 8L, 8L, 8L, 9L, 10L, 
NA, 9L, 8L, 9L, 9L, 8L, 7L, 8L, 9L, 9L, 7L, 9L, 10L, 7L, 7L, 
8L, 10L, 12L, 10L, 7L, 8L, 6L, 8L, 7L, NA, 10L, 8L, 8L, 10L, 
NA, 7L, 9L, 10L, 1L, 8L, 10L, 8L, NA, 12L, 11L, 8L, 8L, 5L, 6L, 
6L, 1L, 1L, 9L, 7L, 7L, 10L, 6L, 8L, 8L, 8L, NA, 8L, 9L, 6L, 
1L, 8L, 11L, 7L, 7L, 8L, NA, 9L, 8L, 7L, 8L, 10L, 8L, 10L, 7L, 
7L, 9L, 10L, 10L, 7L, 11L, 6L, 6L, 6L, 7L, 6L, 4L, 8L, NA, 10L, 
7L, 9L, 9L, 10L, 11L, 8L, 2L), April.lay.date = c(24L, 18L, 17L, 
39L, 17L, 16L, 18L, 21L, 30L, 17L, 21L, 17L, 18L, 21L, 22L, 23L, 
17L, 20L, 21L, 25L, 21L, 26L, 20L, 25L, 16L, 17L, 18L, 40L, 24L, 
24L, 23L, 19L, 19L, 15L, 22L, 18L, NA, 19L, 23L, 22L, 20L, 21L, 
23L, 16L, 17L, 24L, 26L, 19L, 22L, 21L, 24L, 20L, 18L, 14L, 10L, 
23L, 19L, 9L, 20L, 19L, NA, 13L, 17L, 14L, 20L, NA, 26L, 18L, 
21L, 25L, 18L, 19L, 19L, NA, 19L, 20L, 18L, 20L, 25L, 24L, 26L, 
25L, 40L, 18L, 22L, 21L, 11L, 20L, 17L, 20L, 16L, NA, 22L, 17L, 
24L, 20L, 20L, 21L, 38L, 20L, 33L, NA, 41L, 24L, 16L, 18L, 18L, 
26L, 13L, 21L, 17L, 13L, 16L, 16L, 26L, 16L, 34L, 16L, 10L, 15L, 
10L, 1L, 14L, NA, 12L, 10L, 8L, 14L, 16L, 13L, 18L, 20L), April.hatch.date = c(45L, 
NA, 39L, 54L, 37L, 36L, 37L, 42L, 48L, 44L, NA, 37L, 41L, 42L, 
44L, 44L, 39L, 42L, 45L, 50L, 41L, 48L, 43L, 44L, 38L, 39L, 44L, 
57L, 45L, 46L, 46L, 41L, 39L, 37L, 43L, 40L, NA, 41L, 43L, 46L, 
42L, 41L, 43L, 38L, 38L, 46L, 46L, 41L, 46L, 40L, 42L, 41L, 37L, 
36L, 32L, 41L, NA, 29L, 39L, 39L, NA, 36L, 38L, 34L, 43L, NA, 
46L, 41L, 45L, NA, 39L, 39L, 38L, NA, 40L, 41L, 39L, 40L, NA, 
41L, NA, NA, NA, 38L, NA, 44L, 33L, 40L, 40L, 42L, 37L, NA, 42L, 
39L, 46L, NA, 41L, 44L, 56L, 41L, 50L, NA, 52L, 43L, 34L, 37L, 
NA, 47L, 36L, 39L, 36L, 34L, NA, 37L, 44L, 39L, 52L, 34L, 28L, 
35L, 29L, NA, 34L, NA, 34L, 29L, 35L, 35L, 40L, 35L, 39L, NA), 
    Lay.date = c("24-04-2022", "18-04-2022", "17-04-2022", "09-05-2022", 
    "17-04-2022", "16-04-2022", "18-04-2022", "21-04-2022", "30-04-2022", 
    "17-04-2022", "21-04-2022", "17-04-2022", "18-04-2022", "21-04-2022", 
    "22-04-2022", "23-04-2022", "17-04-2022", "20-04-2022", "21-04-2022", 
    "25-04-2022", "21-04-2022", "26-04-2022", "20-04-2022", "25-04-2022", 
    "16-04-2022", "17-04-2022", "18-04-2022", "10-05-2022", "24-04-2022", 
    "24-04-2022", "23-04-2022", "19-04-2022", "19-04-2022", "15-04-2022", 
    "22-04-2022", "18-04-2022", "", "19-04-2022", "23-04-2022", 
    "22-04-2022", "20-04-2022", "21-04-2022", "23-04-2022", "16-04-2022", 
    "17-04-2022", "24-04-2022", "26-04-2022", "19-04-2022", "22-04-2022", 
    "21-04-2022", "24-04-2022", "20-04-2022", "18-04-2022", "14-04-2022", 
    "10-04-2022", "23-04-2022", "19-04-2022", "09-04-2022", "20-04-2022", 
    "19-04-2022", "", "13-04-2022", "17-04-2022", "14-04-2022", 
    "20-04-2022", "", "26-04-2022", "18-04-2022", "21-04-2022", 
    "25-04-2022", "18-04-2022", "19-04-2022", "19-04-2022", "", 
    "19-04-2022", "20-04-2022", "18-04-2022", "20-04-2022", "25-04-2022", 
    "24-04-2022", "26-04-2022", "25-04-2022", "10-05-2022", "18-04-2022", 
    "22-04-2022", "21-04-2022", "11-04-2022", "20-04-2022", "17-04-2022", 
    "20-04-2022", "16-04-2022", "", "22-04-2022", "17-04-2022", 
    "24-04-2022", "20-04-2022", "20-04-2022", "21-04-2022", "08-05-2022", 
    "20-04-2022", "03-05-2022", "", "11-05-2022", "24-04-2022", 
    "16-04-2022", "18-04-2022", "18-04-2022", "26-04-2022", "13-04-2022", 
    "21-04-2022", "17-04-2022", "13-04-2022", "16-04-2022", "16-04-2022", 
    "26-04-2022", "16-04-2022", "04-05-2022", "16-04-2022", "10-04-2022", 
    "15-04-2022", "10-04-2022", "01-04-2022", "14-04-2022", "", 
    "12-04-2022", "10-04-2022", "08-04-2022", "14-04-2022", "16-04-2022", 
    "13-04-2022", "18-04-2022", "20-04-2022"), Hatch.date = c("15-05-2022", 
    "", "09-05-2022", "24-05-2022", "07-05-2022", "06-05-2022", 
    "07-05-2022", "12-05-2022", "18-05-2022", "14-05-2022", "", 
    "07-05-2022", "11-05-2022", "12-05-2022", "14-05-2022", "14-05-2022", 
    "09-05-2022", "12-05-2022", "15-05-2022", "20-05-2022", "11-05-2022", 
    "18-05-2022", "13-05-2022", "14-05-2022", "08-05-2022", "09-05-2022", 
    "14-05-2022", "27-05-2022", "15-05-2022", "16-05-2022", "16-05-2022", 
    "11-05-2022", "09-05-2022", "07-05-2022", "13-05-2022", "10-05-2022", 
    "", "11-05-2022", "13-05-2022", "16-05-2022", "12-05-2022", 
    "11-05-2022", "13-05-2022", "08-05-2022", "08-05-2022", "16-05-2022", 
    "16-05-2022", "11-05-2022", "16-05-2022", "10-05-2022", "12-05-2022", 
    "11-05-2022", "07-05-2022", "06-05-2022", "02-05-2022", "11-05-2022", 
    "", "29-04-2022", "09-05-2022", "09-05-2022", "", "06-05-2022", 
    "08-05-2022", "04-05-2022", "13-05-2022", "", "16-05-2022", 
    "11-05-2022", "15-05-2022", "", "09-05-2022", "09-05-2022", 
    "08-05-2022", "", "10-05-2022", "11-05-2022", "09-05-2022", 
    "10-05-2022", "", "11-05-2022", "", "", "", "08-05-2022", 
    "", "14-05-2022", "03-05-2022", "10-05-2022", "10-05-2022", 
    "12-05-2022", "07-05-2022", "", "12-05-2022", "09-05-2022", 
    "16-05-2022", "", "11-05-2022", "14-05-2022", "26-05-2022", 
    "11-05-2022", "20-05-2022", "", "22-05-2022", "13-05-2022", 
    "04-05-2022", "07-05-2022", "", "17-05-2022", "06-05-2022", 
    "09-05-2022", "06-05-2022", "04-05-2022", "", "07-05-2022", 
    "14-05-2022", "09-05-2022", "22-05-2022", "04-05-2022", "28-04-2022", 
    "05-05-2022", "29-04-2022", "", "04-05-2022", "", "04-05-2022", 
    "29-04-2022", "05-05-2022", "05-05-2022", "10-05-2022", "05-05-2022", 
    "09-05-2022", ""), Num.fledglings = c(0L, 0L, 7L, 0L, 9L, 
    8L, 8L, 3L, 4L, 2L, 0L, 6L, 3L, 0L, 2L, 0L, 9L, 5L, 5L, 0L, 
    8L, 0L, 0L, 2L, 11L, 9L, 4L, 2L, 0L, 4L, 0L, 8L, 8L, 4L, 
    9L, 9L, 0L, 8L, 6L, 4L, 3L, 7L, 5L, 6L, 7L, 0L, 0L, 3L, 0L, 
    6L, 0L, 0L, 10L, 10L, 10L, 6L, 0L, 6L, 6L, 7L, 0L, 10L, 8L, 
    7L, 0L, 0L, 3L, 0L, 4L, 0L, 0L, 8L, 5L, 0L, 3L, 3L, 8L, 7L, 
    0L, 6L, 0L, 0L, 0L, 9L, 0L, 4L, 10L, 6L, 8L, 6L, 6L, 0L, 
    8L, 9L, 0L, 0L, 8L, 5L, 0L, 4L, 3L, 0L, 6L, 0L, 7L, 4L, 0L, 
    3L, 7L, 5L, 7L, 8L, 0L, 9L, 6L, 9L, 6L, 5L, 6L, 6L, 3L, 0L, 
    8L, 0L, 9L, 6L, 6L, 0L, 10L, 11L, 0L, 0L)), row.names = c(NA, 
-132L), class = "data.frame")

Here is the Shiny code

ui <- dashboardPage(
  
  #### Title ####
  
  dashboardHeader(title = "Breeding Season 2022", titleWidth = 200),
  
  
  #### Sidebar ##### 
  
  dashboardSidebar(
    #### sidebar menu ####    
    sidebarMenu(
      menuItem("Home", tabName = "dashboard", icon = icon("fa-bird")),
      menuItem("Laydate & Hatchdate", icon = icon("th"), tabName = "Laydate"),
      menuItem("Clutch size across Wytham",
               icon = icon("fa-solid fa-egg", lib = "font-awesome"), tabName = "ClutchMap")
      
      
      
    )
  ),
  
  
  
  ##### Dashboard Body ######
  dashboardBody(
    tabItems(
      #first tab
      tabItem(
        tabName = "dashboard",
        #### fluid row 1 Info  ####        
        fluidRow(
          strong(h1("Map of Wytham Woods and nest boxes", align = "center")),
          p(h4("Below is some information about the numbers of nests built 
        (though these won't all have contained eggs), also about average clutch sizes, both for the most recent breeding
         season and the historical average.")),
        p(h4("Choosing a species from the drop down menu below will show the nest boxes for that species on the map. 
           You can also view the boxes which were unoccupied. Clicking on any box will display some information about that box" ))
        ),
        
        ##### Fluid row 2 Nest Numbers ######
        fluidRow(
          infoBoxOutput('GretiNest', width = 3), #make info boxes with no of nests
          infoBoxOutput("BlutiNest", width = 3),
          infoBoxOutput("MartiNest", width = 3),
          infoBoxOutput("CoatiNest", width = 3)
        ),
        ##### fluid Row 3 CLutch Size ino ####
        fluidRow(
          infoBoxOutput("GretiEggs", width = 3), #make info boxes with mean clutch size
          infoBoxOutput("BlutiEggs", width = 3),
          infoBoxOutput("MartiEggs", width = 3),
          infoBoxOutput("CoatiEggs", width = 3)
        ),
        ##### fluid row 4 Map
        fluidRow(
          title ="Map of Wytham",
          sidebarLayout(
            sidebarPanel(
              selectInput("Species", label = "Species", choices = unique(df$Species), selected = "Great tit")
            ),
            mainPanel(
              leafletOutput("NestMap", width = "900px", height = "700px"))),
          
          
          
        )
      ),
      
      
      ##### Tab item 2 Laydate and hatchdate ########
      tabItem(tabName = "Laydate",
              plotOutput("laydate22"),
              plotOutput("hatchdate22")
      ),
      
      tabItem(
        selectInput("ClutchSp", label = "Species", 
                    choices = unique(df$Species), 
                    selected = "Great tit"),
        
        tabName = "ClutchMap",
        leafletOutput("Cmap", width = "900px", height = "700px")
        
        
        
        
        
        
        
      )
    )
    
    
    
    
  )
  
  
  
)





######################## SERVER ######################################

server <- function(input, output) {
  
  spcol<-colorFactor(palette = "viridis", df$Species)
  eggcol<-colorFactor(palette = "viridis", df$Clutch.size )
  
  
  ##### Output 1 Nest numbers outputs ####
  output$GretiNest<- renderInfoBox({
    
    
    GretiNest<- df %>% #clean data to produce count of no of nests
      group_by(Species) %>%
      summarise(count = n())
    
    Greti<- GretiNest[3,2]
    infoBox("Great tit Nests", Greti, icon = icon("feather"),  color = "green")
    
    
  })
  output$BlutiNest<- renderInfoBox({
    
    GretiNest<- df %>%
      group_by(Species) %>%
      summarise(count = n())
    Bluti<- GretiNest[1,2]
    infoBox("Blue tit Nests", Bluti, icon = icon("feather"),  color = "aqua")
    
  })
  output$MartiNest<- renderInfoBox({
    GretiNest<- df %>%
      group_by(Species) %>%
      summarise(count = n())
    
    Marti<- GretiNest[4,2]
    infoBox("Marsh tit Nests", Marti, icon = icon("feather"),  color = "teal")
    
  })
  output$CoatiNest<- renderInfoBox({
    GretiNest<- df %>%
      group_by(Species) %>%
      summarise(count = n())
    
    Coati<- GretiNest[2,2]
    infoBox("Coal tit Nests", Coati, icon = icon("feather"),  color = "black") 
  })
  
  
  
  
  
  
  ##### Output 3 Map#####  
  output$NestMap <- renderLeaflet({
    
    
    
    leaflet() %>% addTiles() %>% 
      setView(lng = -1.324640, lat = 51.770462, zoom = 14) %>%
      addCircleMarkers(lng = df$lon, lat = df$lat, color = spcol(df$Species), radius = 5,
                       stroke = F, fillOpacity = 1,
                       popup = paste("<h6>Nest box info</h6>","Name:",
                                     df$nestbox, "<br>", "Laydate:", 
                                     df$Lay.date, "<br>", "Clutch Size:",
                                     df$Clutch.size,"<br>",
                                     "Hatch Date:", df$Hatch.date,"<br>",
                                     "No. of Fledged Chicks:", df$Num.fledglings,  sep = " ") )
    
  })
  
  observeEvent(input$Species, {
    
    if(input$Species != "")
    {
      leafletProxy("NestMap") %>% clearShapes() %>% clearMarkers()
      index = which(df$Species == input$Species)
      leafletProxy("NestMap")%>%  
        addCircleMarkers(lng = df$lon[index], lat = df$lat[index],color = spcol(df$Species[index]),
                         radius = 5, stroke = F, fillOpacity = 1,
                         popup = paste("<h6>Nest box info</h6>","Name:", df$nestbox[index], "<br>", "Laydate:", df$Lay.date[index], "<br>", "Clutch Size:", df$Clutch.size[index],
                                       "<br>",
                                       "Hatch Date:", df$Hatch.date[index], "<br>", "No. of Fledged Chicks:", df$Num.fledglings[index], sep = " "))
    }
  })
  ##### Lay date and Hatchdate plots#####  
  output$laydate22 <- renderPlot({
    df %>%
      ggplot(aes(April.lay.date, fill = Species)) + geom_bar() +
      scale_x_continuous(limits = c(0,70),breaks = seq(0,70, by = 10)) +
      ggtitle("Laydate 2022") +
      theme(plot.title = element_text(hjust = 0.5))+
      xlab("April Lay Date (days since April 1st)")+
      ylab("No. of Nests")+
      theme_classic()
    
  })
  output$hatchdate22<- renderPlot({
    df %>%
      ggplot(aes(April.hatch.date, fill = Species)) + geom_bar() +
      scale_x_continuous(limits = c(0,70),breaks = seq(0,70, by = 10)) +
      ggtitle("Hatchdate 2022") +
      theme(plot.title = element_text(hjust = 0.5))+
      xlab("April Hatch Date (days since April 1st)")+
      ylab("No. of Nests")+
      theme_classic() 
  })
  
  output$Cmap <- renderLeaflet({
    
    leaflet() %>% addTiles() %>% 
      setView(lng = -1.324640, lat = 51.770462, zoom = 14) %>%
      addCircleMarkers(lng = df$lon, lat = df$lat, color = eggcol(df$Clutch.size), radius = 5,
                       stroke = F, fillOpacity = 1,
                       popup = paste("<h6>Nest box info</h6>","Name:",
                                     df$nestbox, "<br>", "Laydate:", 
                                     df$Lay.date, "<br>", "Clutch Size:",
                                     df$Clutch.size,"<br>",
                                     "Hatch Date:", df$Hatch.date,"<br>",
                                     "No. of Fledged Chicks:",
                                     df$Num.fledglings,  sep = " ")
      )%>%
      addLegend('bottomright', pal = eggcol, values = df$Clutch.size,
                title = 'Clutch Size',
                opacity = 2)
    
  })
  
  observeEvent(input$ClutchSp, {
    
    if(input$ClutchSp != "")
    {
      leafletProxy("Cmap") %>% clearShapes() %>% clearMarkers()
      index = which(df$Clutch.size == input$ClutchSp)
      leafletProxy("Cmap")%>%  
        addCircleMarkers(lng = df$lon[index], 
                         lat = df$lat[index],
                         color = eggcol(df$Clutch.size[index]),
                         radius = 5, stroke = F, fillOpacity = 1,
                         popup = paste("<h6>Nest box info</h6>","Name:",
                                       df$nestbox[index],
                                       "<br>", "Laydate:",
                                       df$Lay.date[index], "<br>", "Clutch Size:", df$Clutch.size[index],
                                       "<br>",
                                       "Hatch Date:",
                                       df$Hatch.date[index], 
                                       "<br>", "No. of Fledged Chicks:",
                                       df$Num.fledglings[index], sep = " "))
    }
  })
  
}

shinyApp(ui, server)

On the sidebar menu the item called "Clutch size across Wytham", I would just like to move the Input widget (or the map) over to the right hand side of the page, so that a) the drop down doesn't get obscured by the map (there may be a way to alter the code so that is displays over the top of the map?) and b) so that I can add some text underneath. I have tried using fluidrow but can't quite get it to work. I have also tried moving the zoom control on the map by adding

library(htmlwidgets)

leaflet() %>% addTiles() %>% 
      setView(lng = -1.324640, lat = 51.770462, zoom = 14) %>%
      addCircleMarkers(lng = df$lon, lat = df$lat, color = eggcol(df$Clutch.size), radius = 5,
                       stroke = F, fillOpacity = 1,
                       popup = paste("<h6>Nest box info</h6>","Name:",
                                     df$nestbox, "<br>", "Laydate:", 
                                     df$Lay.date, "<br>", "Clutch Size:",
                                     df$Clutch.size,"<br>",
                                     "Hatch Date:", df$Hatch.date,"<br>",
                                     "No. of Fledged Chicks:",
                                     df$Num.fledglings,  sep = " ")
      )%>%
      addLegend('bottomright', pal = eggcol, values = df$Clutch.size,
                title = 'Clutch Size',
                opacity = 2) %>%
      onRender(
        "function(el, x) {
          L.control.zoom({
            position:'bottomright'
          }).addTo(this);
        }")

But then I end up with two zoom controls, one top left and one above the legend.

Guidance appreciated.

enter image description here

McMahok
  • 348
  • 2
  • 13
  • That's not really a *minimal* example! Try wrapping the elements you want to position within a call to `column()`, and specify `width=xxx`, where `xxx` is an integer between 1 and 12 and widths within a `fluidRow` sum to 12. Details on the RStudio website and online help. – Limey Aug 01 '22 at 08:36
  • Appreciate the feedback but it is difficult to produce a minimal example that reproduces the problem I'm trying to solve. Above I did mention that I tried using ```FluidRow``` , but to no avail. – McMahok Aug 01 '22 at 08:45

0 Answers0