标签: shiny

R Shiny循环显示多个图

好的,我有你可以在下面运行的代码.我想修改这段代码:

https://gist.github.com/wch/5436415/

这样就可以使用UI的输入动态设置max_plots.UI的输入也是动态的.

这是我的UI.R:

shinyUI(pageWithSidebar(
  headerPanel("Dynamic number of plots"),
  sidebarPanel(
    selectInput("Desk", "Desk:" ,  c("A","B")),
   uiOutput("choose_Product"),
uiOutput("choose_File1"),
uiOutput("choose_Term1"),
sliderInput("n", "Number of plots", value=1, min=1, max=5)
  ),

  mainPanel(
    # This is the dynamic UI for the plots
    h3("Heading 1"),
    uiOutput("plots"),
   h3("Heading 2")
  )
))
Run Code Online (Sandbox Code Playgroud)

这是我的Server.R:

shinyServer(function(input, output) {

  output$choose_Product <- renderUI({
    selectInput("Product", "Product:", as.list( c("Product1","Product2","Product3")))
  })

  output$choose_File1 <- renderUI({
selectInput("File1", "File1:", as.list(c("File1","File2","File3")))
  })

# Insert the right number of plot output objects into the web page

  output$plots <- renderUI({
      plot_output_list <- lapply(1:input$n, …
Run Code Online (Sandbox Code Playgroud)

r shiny

0
推荐指数
1
解决办法
5464
查看次数

心理软件包的pca:如何仅获取解释百分比的总方差和模型拟合度量?

在我正在构建的一个闪亮应用程序中,我只想显示主要函数(r包psych)的输出的解释方差和模型拟合度量。我研究了输出的结构,但无意间(也许有些奇怪)无法找到这些值的确切位置。有谁知道如何从输出中获取这些值?

r principal psych shiny

0
推荐指数
1
解决办法
754
查看次数

RStudio Shiny tabsetPanel position ="right"

我使用的是RStudio v0.99.473和Shiny v0.13.0.在我的页面上,我在fluidRow中有一个tabsetPanel,上面有多个标签.我可以使用可选的position ="below"将标签的位置从fluidRow的顶部移动到底部.但是,当我将位置设置为"左"或"右"时,选项卡仍保留在页面顶部.我尝试输入type ="tabs"以确保它不是"丸"类型,但这没有任何区别.有人可以向我解释为什么这不起作用.

以下代码有效:

tabsetPanel(position = "below",
  tabPanel("Plot), 
  tabPanel("Summary"), 
  tabPanel("Table")
)
Run Code Online (Sandbox Code Playgroud)

此代码没有,标签保留在上面的默认位置.

tabsetPanel(position = "right",
  tabPanel("Plot"), 
  tabPanel("Summary"), 
  tabPanel("Table")
)
Run Code Online (Sandbox Code Playgroud)

tabs rstudio shiny

0
推荐指数
1
解决办法
1264
查看次数

R闪亮互动情节标题为ggplot

我正在尝试创建能够显示交互式绘图标题的Shiny App(取决于x轴的选择值)

很简单的例子:

library(shiny)
library(DT)
library(ggplot2)

x <- as.numeric(1:1000000)
y <- as.numeric(1:1000000)
z <- as.numeric(1:1000000)
data <- data.frame(x,y, z)

shinyApp(
  ui = fluidPage(selectInput(inputId = "yaxis", 
                             label = "Y-axis",
                             choices = list("x","y","z"), 
                             selected = c("x")),
  dataTableOutput('tableId'),
                 plotOutput('plot1')),
  server = function(input, output) {    
    output$tableId = renderDataTable({
      datatable(data, options = list(pageLength = 10, lengthMenu=c(10,20,30)))
    })
    output$plot1 = renderPlot({
      filtered_data <- data[input$tableId_rows_all, ]
      ggplot(data=filtered_data, aes_string(x="x",y=input$yaxis)) + geom_line()  
    })
  }
)  
Run Code Online (Sandbox Code Playgroud)

我试过这段代码:

ggtitle("Line plot of x vs",input$yaxis)
Run Code Online (Sandbox Code Playgroud)

它没有工作,情节没有显示,给我一个错误:

Warning: Error in ggtitle: unused argument (input$yaxis) …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 shiny

0
推荐指数
1
解决办法
1969
查看次数

使用Shiny Table时,如何使日期以日期格式显示?

我一直想让日期显示在Shiny表中。我进行了一些研究,发现过去xtable在Shiny上效果不佳。有关SO的问题有两个。一个常规参考可以在这里找到R:xtable和date

我的问题是1)我在使用Shiny编程并使用方面是个新手xtable。2)我不熟悉使用POSIXct。3)我不理解上面链接中提供的解决方案。

请为下面的基本代码提供帮助。这个想法是有人会每天使用此应用程序输入数据。这些数据将存储在.csv中。当存储在.csv中时,仅存储R日期的数值。这也是Shiny表上显示的内容。请教我如何在表格和.csv文件中正确设置格式。

在检查下面的代码之前,请知道将存储一个带有标题日期A,B的.csv文件。让我们将此文件称为“日志”,它将存储在本地。这是代码:

library(shiny)

log <- read.table("V:\\My\\Path\\log.csv",sep=",",header=T)

ui <- fluidPage(

  sidebarLayout(

    sidebarPanel(width=2,

                 #Enter Date
                 dateInput("date","Date",min="2016-07-04", max = "2017-07-04"),

                 #Enter Combo
                 selectInput(inputId = "a", "A", c("Choose one" = "","A1", "A2", "A3"), multiple = FALSE, selectize = TRUE, width = NULL, size = NULL),

                 #Enter Number
                 numericInput(inputId = "b", "Favorite Number", NULL, min = 0, max = NA),

                 #Enter Submit to write info to file
                 actionButton(inputId = "submit", "Submit", icon = NULL, width = NULL) …
Run Code Online (Sandbox Code Playgroud)

csv datetime r xtable shiny

0
推荐指数
1
解决办法
2242
查看次数

使用renderUI在R Shiny中插入额外的tabPanel

我正在尝试将 renderUI 创建的选项卡附加到现有选项卡集。最小的例子:

ui <- fluidPage(sidebarLayout(sidebarPanel(),
                              mainPanel(tabsetPanel(
                                tabPanel("static_tab"),
                                uiOutput('ui_tab')
                              ))))
server <- function(input, output) {
  output$ui_tab <- renderUI({
    tabPanel("render_tab", p('it worked'))
  })
}
shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)

我可以渲染整个 tabsetPanel,但不能渲染现有 tabsetPanel 中的单个选项卡。

r tabpanel shiny

0
推荐指数
1
解决办法
726
查看次数

如何在 R Shiny 中为长文本添加“阅读更多”和“阅读更少”功能?

我正在尝试在我的 Shiny 应用程序中为长文本添加“阅读更多”或“阅读更少”功能。我与 JS/ html 相关的知识有限,因此如果有任何有关闪亮、js 或 html 之间通信信息的帮助,那将会有所帮助。

我参考了本教程,但无法理解如何在闪亮的应用程序中实现相同的功能。

我正在尝试使用以下代码。

library(shiny)
library(htmltools)
library(htmlwidgets)

jscode <- 
  'shinyjs.myFunction = function() {
    var dots = document.getElementById("dots");
    var moreText = document.getElementById("more");
    var btnText = document.getElementById("myBtn");

    if (dots.style.display === "none") {
      dots.style.display = "inline";
      btnText.innerHTML = "Read more";
      moreText.style.display = "none";
    } else {
      dots.style.display = "none";
      btnText.innerHTML = "Read less";
      moreText.style.display = "inline";
    }
  }'

css <- "#more {display: none;}"

ui <- fluidPage(
  shinyjs::useShinyjs(),
  shinyjs::extendShinyjs(
    text = jscode,
    functions = c('myFunction') …
Run Code Online (Sandbox Code Playgroud)

html javascript r shiny

0
推荐指数
1
解决办法
626
查看次数

R+Shiny:读取文件并使用其内容

请在下面找到我在网上找到的脚本示例(可能来自 Rstudio),用于创建一个简单的应用程序来读取各种平面文件并输出表格。我添加了一些创建应用程序可以读取的文件“test_input_file.csv”的内容。

我迷失了一个非常简单的任务:读取 csv 文件后,我有一个 tibble 并将其呈现为表格。我如何直接访问这个 tibble 来用它做其他事情?例如用plotly绘制它,进行一些统计等......?非常感谢

library(shiny)
library(tidyverse)


tt <- tibble(AA=seq(10), BB=seq(10)*2, CC=seq(10)*3 )

write_csv(tt, "test_input_file.csv")

rm(tt)

# Define UI for data upload app ----
ui <- fluidPage(

  # App title ----
  titlePanel("Uploading Files"),

  # Sidebar layout with input and output definitions ----
  sidebarLayout(

    # Sidebar panel for inputs ----
    sidebarPanel(

      # Input: Select a file ----
      fileInput("file1", "Choose CSV File",
                multiple = FALSE,
                accept = c("text/csv",
                         "text/comma-separated-values,text/plain",
                         ".csv", "space")),

      # Horizontal line ----
      tags$hr(),

      # Input: …
Run Code Online (Sandbox Code Playgroud)

r shiny shinyapps

0
推荐指数
1
解决办法
2477
查看次数

Rshiny 无法输出 ggstatsplot

我尝试在 Rshiny 中使用 ggstats 绘制箱提琴图。我收到错误无法转换为符号。尽管我已经将输入作为符号传递,但我仍然面临这个错误。数据表没有问题,因为我尝试从 Rshiny 中绘制它并且它有效。有人知道为什么吗?

用户界面

library (ggstatsplot)
library (shiny)

total_data <- read_rds('data/total_data.rds')


ui <- fluidPage(

    # Application title
    titlePanel("Trial"),

    # Sidebar with a slider input for number of bins 
    sidebarLayout(
        sidebarPanel(
          selectInput(inputId = "Weekday",
                      label = "Choose a Weekday Type",
                      choices = c( "Weekday Earnings" = "weekday_earn",
                                   "Weekend Earnings" = "weekend_earn",
                                   "Total Earnings" = "total_earn"
                      ),
                      selected = "total_earn")
        ),

        # Show a plot of the generated distribution
        mainPanel(
           plotOutput("distPlot")
        )
    )
)

Run Code Online (Sandbox Code Playgroud)

输出

server …
Run Code Online (Sandbox Code Playgroud)

r shiny

0
推荐指数
1
解决办法
253
查看次数

R Shiny - 限制每秒按下操作按钮的次数

我正在 Shiny 中进行一些复杂的计算,用户通过 ActionButton 启动。然而,我担心用户在短时间内多次向按钮发送垃圾邮件,这可能会带来大量不必要的计算。我尝试过使用debounce(),但它仍然记录所有按钮点击。这是一个代表:

library(shiny)

ui <- fluidPage(
  actionButton("start", "Press me")
)

server <- function(input, output, session) {
  new_number <- eventReactive(input$start, {
    print("Button press registered!")
    # sleep to imitate a long calculation
    Sys.sleep(1)
    runif(1, 1, 1000)
  }) %>% debounce(millis = 3000)
  
  observeEvent(new_number(),
               print(new_number()))
}

shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)

尝试运行该应用程序并尽可能快地单击。

它显示该按钮被记录为被按下多次,每次都会停止该过程完整的时间。
输出值仅打印一次,而不是单击按钮的次数,我怀疑这可能有用。但我不知道如何注册,例如,每秒最多按下一个按钮。

throttling r timing shiny

0
推荐指数
1
解决办法
37
查看次数

标签 统计

shiny ×10

r ×9

csv ×1

datetime ×1

ggplot2 ×1

html ×1

javascript ×1

principal ×1

psych ×1

rstudio ×1

shinyapps ×1

tabpanel ×1

tabs ×1

throttling ×1

timing ×1

xtable ×1