我希望在我的Shiny R应用程序中有一个工具提示.有没有简单的方法来实现这一目标?现在,我正在创建一个密度图,我想要一个简单的工具提示,显示"点击这里滑过几年",同时将鼠标悬停在滑块YEAR上.
用户界面:
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("Density Map"),
sidebarPanel(
sliderInput("slider_year", "YEAR:",
min = 2001, max = 2011, value = 2009,
format="####", locale="us"
)
)
),
mainPanel(
plotOutput("event_heatmap_map", width = "100%", height = "100%")
)
))
Run Code Online (Sandbox Code Playgroud)
服务器代码:
library(shiny)
library(ggmap)
library(ggplot2)
mydata <- read.csv("/var/shiny-server/www/dMetrics.csv")
shinyServer(function(input, output) {
output$event_heatmap_map <- renderPlot(width = "auto", height = 640,{
slice_year <- mydata[mydata$YEAR==input$slider_year,]
map <- get_map(c(lon = -55.3632715, lat = 31.7632836), zoom = 3, source = 'google', maptype = c("terrain"), messaging = FALSE, color = 'color') …Run Code Online (Sandbox Code Playgroud) 我在数据表的帮助下编写了一个闪亮的应用程序,我想制作一些小方块来解释每个列的含义.理想情况下,当您将光标移动到列的名称上时,我希望它们出现.
这是一个应用程序:
ui.R
library(shiny)
data(iris)
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
fluidRow(
column(12,
wellPanel(
radioButtons("species", label="Species:",
choices=levels(iris$Species),
selected=levels(iris$Species)[1]
)
)
)
)
),
mainPanel(
fluidRow(column(12,
dataTableOutput("table1")
)
)
)
)
)
)
Run Code Online (Sandbox Code Playgroud)
server.R
library(shiny)
library(dplyr)
library(tidyr)
data(iris)
shinyServer(function(input, output) {
iris1 <- reactive({
iris %>%
filter(Species %in% input$species)
})
output$table1 <- renderDataTable({
iris1()
})
})
Run Code Online (Sandbox Code Playgroud)
当你将courser移到Species列名称上时,我想要像这样:

它甚至可能吗?请帮忙.
当用户将数据广告的行名称悬停/点击时,我不得不尝试包含类似工具提示或popover的附加信息,因此他们不必查找某些定义,我目前在不同的tabPanel.这是一个有效的例子:
library(shiny)
library(DT)
library(shinyBS)
# Define server for the Shiny app
shinyServer(function(input, output,session) {
tdata <- as.data.frame(iris)
# Render table here
output$mytable <- DT::renderDataTable(DT::datatable(
tdata[1:5,],
options = list(paging = FALSE, searching = FALSE, info = FALSE, sort = FALSE,
columnDefs=list(list(targets=1:4, class="dt-right")) ),
rownames = paste("rowname",1:5),
container = htmltools::withTags(table(
class = 'display',
thead(
tr(lapply(rep(c('ratios','name1', 'name2', 'name3','name4','name5'), 1),th))
)
))
))
}) # end of shinyServer function
Run Code Online (Sandbox Code Playgroud)
library(shiny)
library(DT)
library(shinyBS)
shinyUI(
mainPanel(
DT::dataTableOutput("mytable")
)
)
Run Code Online (Sandbox Code Playgroud)
请注意,我已经看到了以下讨论主题,但没有成功: 用于表列的R闪亮鼠标悬停文本,以及在闪亮应用程序中将 …
我想创建一个闪亮的数据表,以突出显示用户鼠标悬停在其上的单元格,以突出显示同一行和同一列中的单元格。它类似于此处显示的内容:https : //datatables.net/examples/api/highlight.html
但是在这个例子中,整个列都被突出显示,我希望它停在鼠标所在的单元格上。
我见过其他有类似问题的问题,比如这个:R 表列的闪亮鼠标悬停文本。但我不知道它是否已经过时,但该代码对我不起作用,它只是显示一个普通的数据表。
以下面的代码为例,我怎样才能做到这一点?
library(shiny)
shinyApp(
ui = fluidPage(
DT::dataTableOutput("mtcarsTable")
),
server = function(input, output) {
output$mtcarsTable <- DT::renderDataTable({
DT::datatable(datasets::mtcars[,1:3],
options = list(rowCallback = JS()
)
)
})
}
)
Run Code Online (Sandbox Code Playgroud)