我有一个闪亮的应用程序,我在R Studio的3个单独的标签中运行:
全局标签:
library(shiny)
library(leaflet)
country = c("Russia", "Mongolia", "China")
latitude = c(64.9, 47.01, 35.6)
longitude = c(91.2, 98.1, 95.6)
photo = c("russia.png", "mongolia.png", "china.png")
text = c("This is Russia", "This is Mongolia", "This is China")
countries = cbind.data.frame(country, latitude, longitude, photo, text)
ui tab:
ui = fluidPage(
hr(),
tags$p("Please click on the button to see the data:"),
actionButton(inputId = "go",
label = "Button!", align = "center"),
hr(),
leafletOutput("basicMap", height = "500px")
)
服务器标签:
server = function(input, output, session) {
readData = eventReactive(input$go, {
countries
})
output$basicMap = renderLeaflet({
leaflet(data = readData()) %>%
addTiles() %>%
addCircleMarkers(data = readData(), lng = ~ longitude, lat = ~ latitude,
popup = ~ paste0("<strong>","", readData()$country, '</strong>',"<br>",
"<br>",
"<img src = ", readData()$photo, ">",
"<br>",
"<strong>","", readData()$text, '</strong>',"<br>"
))
})
}
这样运行正常,在每个弹出窗口中,我有一个标题和一些文本,它们对应于弹出该弹出窗口的数据框中的相关行。对于图像也是如此。但是,我无法自动化图像大小:
请有人帮我这样做吗?谢谢!