خرید بک لینک

Vote count: 0

I’ve a custom built function in R that takes few inputs and retus a data frame as an output. I use the output data frame to plot a Sankey using gvissankey function in googleVis package. So far, all these work well.

Now, I’m trying to integrate the function, plot from gvissankey into a shiny app. For some reason, I’m unable to see the Sankey in the app and I get the following error (“Data has to be a data.frame. See ?data.frame for more details.”), However, the output dataframe is rendered as a table without problem! I have included snippets of code below: (a) code that works well on a stand alone basis and (b) code used in shiny app.

Would you have any suggestions to resolve this issue? Any Idea and suggestions would be greatly appreciated!

Standalone code that works well:

functioname (input1, input 2, input3) 
{
code for manipulating data
retu (dateframe)
}

plot(
    gvisSankey (functioname(input1, input 2, input3), 
               from = "source", to = "target", weight = "value",
               options = list(
                   width = 1200, height = 600,
                   sankey = "{link: {color: { fill: 'grey100' } },
                   node: { width: 40, color: { fill: '#a61d4c' },
                   label: { fontName: 'Calibri', fontSize: 12, color: '#871b47'} 
                   }}"
               ),
               chartid = "SankeyName"
               )
    )

Code used in Shiny app

UI.R

tabPanel("Sankey Panel",
                            sidebarLayout(
                                sidebarPanel(
                                    uiOutput("var1Output"), uiOutput("var2Output"), uiOutput("var2Output") 
                                    )),
                                mainPanel(
                                    plotOutput("sankeyplot"), br(),
                                    DT::dataTableOutput("basicstats2")
                                )))

Server.R

output$var1Output <- renderUI({
selectInput("gbInput", 
some code 
})

similarly for var2 and var3

sankeydata <- reactive({
        FSOSankey(input$var1Input, input$var2Input, input$var3Input)
        })

 output$FSOsankeyplot <- renderGvis({
         gvisSankey(sankeydata, from = "source", to = "target", weight = "value",
                       options = list(
                           width = 1200, height = 600,
                           sankey = "{link: {color: { fill: 'grey100' } },
                    node: { width: 40, color: { fill: '#a61d4c' },
                    label: { fontName: 'Calibri', fontSize: 12, color: '#871b47'} 
                    }}"
                       ),
                        chartid = "Sankey"
            )
        )
     })

output$basicstats2 <- DT::renderDataTable({
        sankeydata
    })

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 11 ارديبهشت 1395 ساعت: 8:08

صفحه بندی