小编act*_*cts的帖子

闪亮服务器中的动态颜色输入

我正在尝试使用 Shiny 创建一个应用程序,我希望用户能够选择图中每条线的颜色。大体思路是在应用程序中导入数据,然后绘制数据中的每个变量。我尝试使用shinysky包中的颜色选择器'jscolorInput',当放置在ui.r文件中时它工作正常,但由于我希望我的应用程序对于上传的每个数据集都是动态的,我需要将颜色选择器放在服务器中。 R,使用反应函数。当放置在服务器中时,'jscolorInput' 不起作用。

我想做的是:

  1. 将颜色选择器重现与数据中变量的数量一样多
  2. 从颜色中获取输入并将其作为绘图中的颜色参数传递

我在闪亮的开发和 stackoverflow 方面都很新,所以请原谅我的错误。

这是一个不起作用的可重现示例。

require(shinysky)
require(shiny)

dat <- data.frame(matrix(rnorm(120, 2, 3), ncol=3))

runApp(list(
ui = bootstrapPage(
    # The reactive colorpicker
    uiOutput('myPanel'),
    # The plot
    plotOutput('plot')
),
server = function(input, output) {
    # Print as many colorpickers as the columns in the dataset
    cols <- reactive({
        n <- ncol(dat)
        for(i in 1:n){
            print(jscolorInput(paste("col", i, sep="_")))    
        }
    })

        output$myPanel <- renderPrint({cols()})
    # Put all the input in a vector
    colors <- reactive({
        n <- …
Run Code Online (Sandbox Code Playgroud)

r shiny shinysky

5
推荐指数
1
解决办法
2096
查看次数

标签 统计

r ×1

shiny ×1

shinysky ×1