diff --git a/app.R b/app.R index b25c6ee..4fed703 100644 --- a/app.R +++ b/app.R @@ -8,7 +8,7 @@ library(rgdal) library(data.table) source("global.R") -source("GKtoWGS.R") +source("functions.R") #### HEADER #### diff --git a/GKtoWGS.R b/functions.R similarity index 70% rename from GKtoWGS.R rename to functions.R index 6597b47..d56df13 100644 --- a/GKtoWGS.R +++ b/functions.R @@ -26,3 +26,19 @@ GKtoWGS <- function(df) { df } } + + +#' Create popup for samples. +populatePopup <- function(x) { + out <- sprintf("
+
animal: %s
+
date: %s
+
sex: %s
+
sample type: %s
+
", + x$animal, + x$date, + x$sex, + x$sample_type) + out +} diff --git a/leaflet.R b/leaflet.R index 5026320..1fbdc8e 100644 --- a/leaflet.R +++ b/leaflet.R @@ -30,7 +30,7 @@ observe({ fillOpacity = 0.2, fillColor = "black", layerId = paste("allMarkers", xy$id, sep = " "), - popup = paste(xy$sample_type, "from", xy$animal, "on", xy$date, sep = " ")) + popup = populatePopup(xy)) if (nrow(picks) > 0) { @@ -53,7 +53,7 @@ observe({ fillColor = ~pal(sample_type), fillOpacity = input$parent_opacity, layerId = paste("aniMarkers", picks$id, sep = " "), - popup = paste(picks$sample_type, "from", picks$animal, "on", picks$date, sep = " ")) + popup = populatePopup(picks)) } } })