我正在尝试做一个非常简单的应用程序。到目前为止,我已经实现了一些基本的人员,如选择图表从下拉菜单和选择值与滑块。下面你可以看到我的代码:
---
title: "Test App"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
library(tidyverse)
library(shinyjs)
library(shinyWidgets)
# Data Set 1
df<-data.frame( cyl=c("4","6","8"),
Multiplier=c(2,4,6)
)
# Data Set 2
df1 <- mtcars
df1$cyl <- as.factor(df1$cyl)
Column {.sidebar}
useShinyjs(rmd = TRUE)
selectInput("clusterNum",
label = h4("Charts"),
choices = list("Chart1" = "Chart1", "Chart2" = "Chart2"),
selected = "Chart1"
)
sidebarPanel(sliderInput("integer", "Integer:",
min = 0, max = 8,
value = 1),)
Column {data-width=650}
Chart
# First chart
Chart1 <- ggplot(df1, aes(x = wt, y = mpg)) +
geom_point()
# Second chart
Chart2 <- reactive({
dplyr::left_join(df, df1, by = c("cyl" = "cyl")) %>%
dplyr::mutate(mpg_new = (mpg * Multiplier * input$integer)) %>%
ggplot(aes(x = wt, y = mpg_new)) +
geom_point()
})
# Visualization of the selected chart
renderPlot({
switch(input$clusterNum,
"Chart1" = Chart1,
"Chart2" = Chart2()
)
})
# Second chart data
Chart2_dat <- reactive({
dplyr::left_join(df, df1, by = c("cyl" = "cyl")) %>%
dplyr::mutate(mpg_new = (mpg * Multiplier * input$integer))
})
# Second chart
Chart2 <- reactive({
Chart2_dat() %>%
ggplot(aes(x = wt, y = mpg_new)) +
geom_point()
})
# Visualization of the selected chart
renderPlot({
switch(input$clusterNum,
"Chart1" = Chart1,
"Chart2" = Chart2()
)
})
但是这里出现了一个问题。也就是说,滑块不是以正常大小显示的,而是以微型显示的,并且无法相应地选择值。有人能帮我调整滑块的大小,使其看起来像下面所示的图像吗?
![](https://i.stack.imgur.com/LkfTu.jpg)
1条答案
按热度按时间62lalag41#
在
sidebarPanel
中添加width = 12
参数: