блестящий - как использовать ggiraph

Мой набор данных выглядит следующим образом....

fund , sharpe , risk
abc , 1.5 , 7
def , 0 , 5

selectInput("n_breaks", label = "Risk Profile:", choices = c(1,2,3,4,5,6,7,8,9,10), selected = 7)

# Reactive 
selectedData <- reactive

  a <- mydata %>% filter(risk==as.numeric(input$n_breaks) & sharpe > 0)


renderPlot

  ggplot(selectedData(), aes(x = sharpe, y = returns, tooltip = fund, data_id = fund, color=sd)) +  geom_point_interactive(size=1)

Я пытаюсь запустить приведенный ниже код в renderplot, и блестящий терпит неудачу. пожалуйста, порекомендуйте

ggiraph(code = {print(gg_point_3)}, tooltip_offx = 20, tooltip_offy = -10 )

person james lim    schedule 23.10.2016    source источник


Ответы (1)


Это пример использования набора данных радужной оболочки.

    library(shiny)
    library(dplyr)
    library(ggplot2)
    library(ggiraph)


    ui <- shinyUI(fluidPage(


       titlePanel("Shiny & ggiraph"),


       sidebarLayout(
          sidebarPanel(
             selectInput("species",
                         "Select species:",
                         selected = "setosa",
                         choices = unique(levels(iris$Species))
                         )
          ),


          mainPanel(
                    ggiraphOutput("plotIris")
          )
       )
    ))


    server <- shinyServer(function(input, output) {
            filterIris <- reactive({
                    filter(iris, Species == input$species)
            })

            output$plotIris <- renderggiraph({
                    gg <- ggplot(filterIris(), aes(x = Sepal.Length, y = Petal.Length))
                    gg <- gg + geom_point_interactive(
                            aes(tooltip = filterIris()$Sepal.Length), size = 2) 
                    ggiraph(code = print(gg))
            })

    })


    shinyApp(ui = ui, server = server)
person Valter Beaković    schedule 23.10.2016