- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
sidebarMenu
中的 MenuItem
有问题。当我添加第三个 MenuItem
(RFM) 时,它似乎在 ui 中呈现为子项,当我单击该项目时,即使在服务器中也没有显示任何内容。R 有相应的功能。这是 sidebarMenu
的屏幕截图
ui.R
dashboardPage(
dashboardHeader(title= "Acquisti Clienti CC"),
dashboardSidebar(
h4("Explorer"),
textInput("cluster","Digita un Codice cliente CC:","H01621"),
selectizeInput('categ',label="Seleziona una Categoria Merceologica",
choices=unique(user_clustering$DESC_CAT_MERC),
selected=c("NOTEBOOK","PC","TABLET/PDA"),
options = NULL,
multiple=TRUE),
#uiOutput("checkcluster"),
sidebarMenu(id="menu",
tags$style(".fa-stats {color:#f2f4f4}"),
tags$style(".fa-th-list {color:#f2f4f4}"),
menuItem("Dashboard", tabName = "dashboard",icon = icon("stats",lib = "glyphicon")),
menuItem("Data", tabName = "Data",icon = icon("th-list",lib = "glyphicon")),
menuItem("RFM",tabname="RFM",icon = icon("dashboard",lib = "glyphicon")) ## That's the item I ve just added
)
),
dashboardBody(
tabItems(
tabItem("dashboard",
fluidRow(
#valueBoxOutput("Spesa_Grafico",width=3),
valueBoxOutput("Spesa_Totale"),
#valueBoxOutput("Spesa_Cluster",width=3),
valueBoxOutput("Clienti_Totali")
),
fluidRow(
box(title="Cluster 1",plotlyOutput('plot1'),
fluidRow(column(4,offset=3,DT::dataTableOutput("plot1_data",width = 10)))),
#DT::dataTableOutput("plot1_data",width = 8),
box(title="Cluster 2",plotlyOutput('plot2'),
fluidRow(column(4,offset=3,DT::dataTableOutput("plot2_data",width = 10)))),
#DT::dataTableOutput("plot2_data",width = 8),
box(title="Cluster 3",plotlyOutput('plot3'),
fluidRow(column(4,offset=3,DT::dataTableOutput("plot3_data",width = 10)))),
#DT::dataTableOutput("plot3_data",width = 8),
box(title="Cluster 4",plotlyOutput('plot4'),
fluidRow(column(4,offset=3,DT::dataTableOutput("plot4_data",width = 10))))
#DT::dataTableOutput("plot4_data",width = 8)
)
)
,
tabItem("Data",
DT::dataTableOutput("Data"),
downloadButton("downloadCsv", "Download as CSV")
),
tabItem("RFM",
fluidRow(
box(title="RFM",plotOutput('plot_rfm')))
)
)
)
)
服务器.R
function(input, output, session) {
# Combine the selected variables into a new data frame
# Radar Chart data
selectedData <- reactive({
categ<-input[["categ"]]
data_plot<- user_clustering_raw %>%filter(DESC_CAT_MERC %in% categ)%>%
group_by(CLUSTER,DESC_CAT_MERC)%>%
dplyr::summarise(VAL_INV=sum(VAL_INV))%>%ungroup()%>%
group_by(CLUSTER)%>%mutate(VAL_INV=VAL_INV/sum(VAL_INV))
return (data_plot)
})
# RFM chart (2nd page....)
selectedData_plot2<-reactive({
clust<-user_clustering_raw[user_clustering_raw$CO_CUST==input$cluster,]$CLUSTER[0]
rfm <- RFM_rec %>%
inner_join(user_clustering_raw%>%select(CO_CUST,CLUSTER)%>%distinct(),by="CO_CUST")%>%
filter(CLUSTER %in% clust)
return (rfm)
})
# Data for summary alongside graph
summary_1<-reactive({
categ<-input[["categ"]]
summary_1<-user_clustering_raw%>%
filter(DESC_CAT_MERC%in% categ)
return (summary_1)
})
# Value box
output$Spesa_Totale <- renderValueBox({
valueBox(
value = prettyNum(round(sum(user_clustering$VAL_INV),0),big.mark=",",decimal.mark = "."),
subtitle = "Spesa Totale",
icon = icon("euro"),width=6
)
})
output$Clienti_Totali <- renderValueBox({
valueBox(
length(unique(user_clustering_raw%>%pull(CO_CUST))),
"Numero Clienti Totali",
icon = icon("users"),width=6
)
})
summary_2<-reactive({
outlier<-data.frame(CO_CUST=attributes(big_outliers),FLAG_OUTLIER=1)
colnames(outlier)<-c("CO_CUST","FLAG_OUTLIER")
data_summary_2<- user_clustering_raw%>%left_join(outlier,by="CO_CUST")%>%
replace_na(list(FLAG_OUTLIER=0))
colnames(data_summary_2)<-c("Codice Cliente", "Categoria Merc.",
"Spesa (EUR)","Cluster","Outlier")
data_summary_2
})
# 1 CLUSTER
output$plot1 <- renderPlotly({
categ<-input[["categ"]]
d1<-selectedData()
d1_clust<-d1%>%filter(DESC_CAT_MERC %in% categ)
d1_clust<-d1_clust%>%filter(CLUSTER==1)
plot_ly(
type = 'scatterpolar',
r = d1_clust$VAL_INV,
theta = d1_clust$DESC_CAT_MERC,
fill = 'toself'
) %>%
layout(
polar = list(
radialaxis = list(
visible = T,
range = c(0,1)
)
),
showlegend = F
)
})
output$plot1_data <- DT::renderDataTable({
plot1_data<-summary_1()
plot1_data<-plot1_data%>%filter(CLUSTER==1)%>%
group_by(DESC_CAT_MERC)%>%
summarise(VAL_INV=sum(VAL_INV),NUMERICA_CLIENTI=n_distinct(CO_CUST))%>%
ungroup()%>%
mutate(VAL_INV_PERC=round(VAL_INV/sum(VAL_INV),3)*100)
plot1_data <- plot1_data[c("DESC_CAT_MERC", "VAL_INV", "VAL_INV_PERC","NUMERICA_CLIENTI")]
colnames(plot1_data)<-c("Cat.Merceologica","Fatturato (EUR)","Fatturato %","Numero Clienti")
DT::datatable(plot1_data,rownames = FALSE,options = list(dom = 't',
columnDefs = list(list(className = 'dt-center', targets = "_all"))))%>%formatCurrency(2:2, '')
})
# 2 CLUSTER
output$plot2 <- renderPlotly({
categ<-input[["categ"]]
d1<-selectedData()
d2_clust<-d1%>%filter(DESC_CAT_MERC %in% categ)
d2_clust<-d2_clust%>%filter(CLUSTER==2)
plot_ly(
type = 'scatterpolar',
r = d2_clust$VAL_INV,
theta = d2_clust$DESC_CAT_MERC,
fill = 'toself',mode="markers"
) %>%
layout(
polar = list(
radialaxis = list(
visible = T,
range = c(0,1)
)
),
showlegend = F
)
})
output$plot2_data <- DT::renderDataTable({
plot2_data<-summary_1()
plot2_data<-plot2_data%>%filter(CLUSTER==2)%>%
group_by(DESC_CAT_MERC)%>%
summarise(VAL_INV=sum(VAL_INV),NUMERICA_CLIENTI=n_distinct(CO_CUST))%>%ungroup()%>%
mutate(VAL_INV_PERC=round(VAL_INV/sum(VAL_INV),3)*100)
plot2_data <- plot2_data[c("DESC_CAT_MERC", "VAL_INV", "VAL_INV_PERC","NUMERICA_CLIENTI")]
colnames(plot2_data)<-c("Cat.Merceologica","Fatturato (EUR)","Fatturato %","Numero Clienti")
DT::datatable(plot2_data,rownames = FALSE,
options = list(dom = 't',
columnDefs = list(list(className = 'dt-center', targets = "_all"))))%>%formatCurrency(2:2, '')
})
# 3 CLUSTER
output$plot3 <- renderPlotly({
categ<-input[["categ"]]
d1<-selectedData()
d3_clust<-d1%>%filter(DESC_CAT_MERC %in% categ)
d3_clust<-d3_clust%>%filter(CLUSTER==3)
plot_ly(
type = 'scatterpolar',
r = d3_clust$VAL_INV,
theta = d3_clust$DESC_CAT_MERC,
fill = 'toself'
) %>%
layout(
polar = list(
radialaxis = list(
visible = T,
range = c(0,1)
)
),
showlegend = F
)
})
output$plot3_data <- DT::renderDataTable({
plot3_data<-summary_1()
plot3_data<-plot3_data%>%filter(CLUSTER==3)%>%
group_by(DESC_CAT_MERC)%>%
summarise(VAL_INV=sum(VAL_INV),
NUMERICA_CLIENTI=n_distinct(CO_CUST))%>%ungroup()%>%
mutate(VAL_INV_PERC=round(VAL_INV/sum(VAL_INV),3)*100)
plot3_data <- plot3_data[c("DESC_CAT_MERC", "VAL_INV", "VAL_INV_PERC","NUMERICA_CLIENTI")]
colnames(plot3_data)<-c("Cat.Merceologica","Fatturato (EUR)","Fatturato %","Numero Clienti")
DT::datatable(plot3_data,rownames = FALSE,options = list(dom = 't',
columnDefs = list(list(className = 'dt-center', targets = "_all"))))%>%
formatCurrency(2:2, '')
})
# 4 CLUSTER
output$plot4 <- renderPlotly({
categ<-input[["categ"]]
d1<-selectedData()
d4_clust<-d1%>%filter(DESC_CAT_MERC %in% categ)
d4_clust<-d4_clust%>%filter(CLUSTER==3)
plot_ly(
type = 'scatterpolar',
r = d4_clust$VAL_INV,
theta = d4_clust$DESC_CAT_MERC,
fill = 'toself'
) %>%
layout(
polar = list(
radialaxis = list(
visible = T,
range = c(0,1)
)
),
showlegend = F
)
})
output$plot4_data <- DT::renderDataTable({
plot4_data<-summary_1()
plot4_data<-plot4_data%>%filter(CLUSTER==4)%>%
group_by(DESC_CAT_MERC)%>%
summarise(VAL_INV=sum(VAL_INV),
NUMERICA_CLIENTI=n_distinct(CO_CUST))%>%
ungroup()%>%mutate(VAL_INV_PERC=round(VAL_INV/sum(VAL_INV),3)*100)
plot4_data <- plot4_data[c("DESC_CAT_MERC", "VAL_INV", "VAL_INV_PERC","NUMERICA_CLIENTI")]
colnames(plot4_data)<-c("Cat.Merceologica","Fatturato (EUR)","Fatturato %","Numero Clienti")
DT::datatable(plot4_data,rownames = FALSE,options = list(dom = 't',
columnDefs = list(list(className = 'dt-center', targets = "_all"))))%>%
formatCurrency(2:2, '')
})
# rfm
output$plot_rfm <- renderPlot({
d<-selectedData_plot2()
adding_point<- d[d$CO_CUST==input$cluster,]
p1 <- ggplot(d,aes(x=FREQ))+
geom_histogram(fill="darkblue",col="white")+
ggtitle("Frequenza Acquisti")+labs(x="Frequenza Acquisti",y="Conteggio")+
geom_point(x=adding_point$FREQ,y=0,col="red",size=4)+
theme(axis.text.x = element_text(angle=45,hjust=1,size=12),
axis.title.x = element_blank(),plot.title = element_text(size=14,face="bold"))
breaks <- pretty(range(d$MONET), n = nclass.FD(d$MONET), min.n = 1)
bwidth <- breaks[2]-breaks[1]
p2 <- ggplot(d,aes(x=round(MONET,0)))+
geom_histogram(fill="darkblue",col="white")+
ggtitle("Valore Monetario Acquisti (EUR)")+labs(x="Valore Monetario",y="Conteggio")+
scale_x_continuous(labels=dollar_format(prefix="€"))+
geom_point(x=adding_point$MONET,y=0,col="red",size=4)+
theme(axis.text.x = element_text(angle=45,hjust=1,size=12),
axis.title.x = element_blank(),plot.title = element_text(size=14,face="bold"))
p3 <- ggplot(d,aes(x=LAST_PURCHASE))+
geom_histogram(fill="darkblue",col="white")+
ggtitle("Ultimo Acquisto (Giorni)")+labs(x="Ultimo Acquisto",y="Conteggio")+
geom_point(x=adding_point$LAST_PURCHASE,y=0,col="red",size=4)+
theme(axis.text.x = element_text(angle=45,hjust=1,size=12),
axis.title.x = element_blank(),plot.title = element_text(size=14,face="bold"))
grid.arrange(p1, p2,p3, nrow = 1)
})
# Data being displayed 2 tabitem
output$Data <- DT::renderDataTable({
DT::datatable(summary_2(),rownames = FALSE)%>% formatStyle(
'Outlier',
target = 'row',
color = styleEqual(c(1, 0), c('red', 'black')))%>%formatCurrency(3:3, '')
})
# Check CO_CLIENTE per errori input utente
output$checkcluster <- renderUI({
if (sum(input$cluster%in% user_clustering_raw$CO_CUST)==0)
print ("Errore! Codice Cliente non presente...")})
}
我希望它足够清楚,请不要降级
最佳答案
你错过了一个大写字母:
menuItem("RFM",tabname="RFM",icon = icon("dashboard",lib = "glyphicon")) ## That's the item I ve just added
tabname
应该是 tabName
。
此外,tabItem("RFM",
应该是 tabItem("rfm",
因为它链接到 id
tabName
参数。
因此,下面给出了一个精简的工作版本 - 最小化代码是我发现问题的方式。希望这对您有所帮助!
library(shiny)
library(shinydashboard)
library(plotly)
ui <- dashboardPage(
dashboardHeader(title= "Acquisti Clienti CC"),
dashboardSidebar(
sidebarMenu(id="menu",
menuItem(text = "Dashboard", tabName = "dashboard",icon = icon("stats",lib = "glyphicon")),
menuItem(text = "Data", tabName = "Data",icon = icon("th-list",lib = "glyphicon")),
menuItem(text = "RFM", tabName="rfm",icon = icon("th-list",lib = "glyphicon"))
)
),
dashboardBody(
tabItems(
tabItem("dashboard",
p('dashboard')
)
,
tabItem("Data",
p('data')
),
tabItem("rfm",
p('rfm')
)
)
)
)
server <- function(input,output){}
shinyApp(ui,server)
关于r - MenuItem 呈现为 subItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51493181/
我想为 MenuItem 实现键盘快捷键。我使用了下面的代码: ` 但是当我按下 CTRL+N 时,InputGestureText 属性没有响应。我正在使用
例子: 菜单 1(可见 = 假) 菜单 2(可见 = 假) 菜单 3(可见 = 真) 当点击 Menu3 时,我希望显示 Menu1 和 Menu2。 @Override public void on
我的应用程序中有菜单。我需要检查用户选择了哪个菜单项并采取适当的措施。我这样做是为了, @Override public boolean onOptionsItemSelected(MenuI
我有以下 xaml: TestItemModel 类仅包含一个 IsSelected bool 属
我是 BlackBerry 的新手,我仍然为 BlackBerry OS 5 开发应用程序。 我知道 BlackBerry 中的 MenuItem 类用于在 Blackberry 中创建菜单项。我的
在页面加载时,JavaScript 使第一个缩略图处于事件状态,但我想根据它正在加载的页面将其更改为第二个、第三个甚至第四个缩略图。 JavaScript 适用于第一个缩略图处于事件状态: $('#m
如何获取已单击的任何给定菜单项的文本? 菜单是动态填充的,所以我似乎仅限于此: Menu.MenuItems.Add(new MenuItem("MenuName", new EventHandle
我有一个"file"MenuItem,我想显示最近打开的文件列表。 这是我现在拥有的 xaml:
我一直在使用 React/Next.js 来使用 Material-UI,但遇到了一个奇怪且持续存在的错误。我无法获取呈现常规垂直下拉菜单。我如何获得 s 垂直渲染? 我搜索了文档,但找不到任何内容。
下面的代码我有问题。当我将鼠标悬停在菜单项上时,departmentsHover 类不会影响菜单项。颜色和背景图像没有改变。 我必须做什么? P.S 我在环境中使用 MS visual Studio
我的 TableViewController 类中有这个奇怪的错误消息 class MenuTableViewController: UITableViewController { filepriva
我正在使用旧版 MainMenu control (with MenuItem s) control in an application, and would like to implement zo
我在 Button 上有一个 ContextMenu,显示时它会显示一个菜单项列表,这很好。如果我将鼠标移到菜单中的某个项目上,它会高亮显示,但当我将鼠标悬停在文本上方和周围时,我也会得到一个辅助高亮
我想向我的 ContextMenu 的某些 MenuItems 添加一个 Ellipse。 遗憾的是我无法让它工作[没有显示任何内容]。 Canvas canvas = new Canvas() {
我有一个基于 MVVM 的 WPF 上下文菜单,并希望将菜单项的可见性绑定(bind)到 IsEnabled其子菜单项的属性。问题是:根MenuItem始终可见,即使所有子菜单项都被禁用。但是在菜单项
我想知道我上面提出的问题的答案。我发现了很多关于这个问题的信息,但仅限于 Java Swing,而且 Action 处理是完全不同的。感谢您的回答,我很抱歉我的英语不好。 最佳答案 你可以做到 Eve
在shinydashboard中,可以创建menuItem(),它们是侧边栏中的选项卡。我希望能够使用标准 input$foo 语法轮询哪个选项卡处于事件状态。 但是,我没能做到。我尝试引用 menu
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 8 年前。 Improve this ques
我有一个菜单,我想点击菜单,但如果你们知道我的意思的话,我不想点击文本。MenuItem 有一个边框或类似的东西,但是当我点击它时它不会重定向到我想要的页面,除非我点击文本。 是否可以单击整个“按钮”
我正在编写一个备份工具。在我的工具之上,我有一个包含两个工具条菜单项的菜单条。我根据我的期望稍微改变了颜色。不关注菜单看起来很棒: 当我现在单击菜单项"file"打开上下文菜单时,颜色变为白色,我无法
我是一名优秀的程序员,十分优秀!