ggvis Ausgabe erscheint nicht in glänzender Anwendung

Ich bin ratlos, was hier falsch ist, und die anderen Threads auf Stack, in denen Benutzer ihre Probleme mit ggvis + shiny diskutieren, scheinen nicht zuzutreffen, obwohl sie sehr ähnlich sind.

Zunächst besteht das Grundproblem darin, dass meine ggvis-Visualisierung nicht in der Shiny-App angezeigt wird. Ich habe eine weitere Registerkarte in meiner Shiny-App, die eine Datentabelle anzeigt, und die funktioniert einwandfrei. Auch wenn ich ggvis auslagere und ggplot2 verwende (wobei der Rest des Codes intakt bleibt, mit Ausnahme der Verwendung einer kompatiblen Funktion in ui.R, die die Visualisierung aufruft), funktioniert das auch einwandfrei. In RStudio werden keine Fehlermeldungen oder Warnungen angezeigt. Ich vermute, ich habe ein Problem mit der Funktion bind_shiny, aber nichts, was ich versucht habe, scheint zu funktionieren.

Hier ist mein server.R Code:

library(shiny)
library(ggvis)
library(dplyr)

#import file created by screener.R

final <- read.csv("final-test.csv") 


 # Define server logic required to complete visualization

shinyServer(function(input, output) {

reactviz <- reactive({allviz <- filter(final, DivYield >= input$Yield[1])
allviz <- filter(allviz, DivYield <= input$Yield[2])
allviz <- filter(allviz, PAYOUTRATIO >= input$PayoutRatio[1])
allviz <- filter(allviz, PAYOUTRATIO <= input$PayoutRatio[2])
allviz <- filter(allviz, PriceSales >= input$PriceSales[1])
allviz <- filter(allviz, PriceSales <= input$PriceSales[2])
allviz <- filter(allviz, MarketCapinMil >= input$MarketCap[1])
allviz <- filter(allviz, MarketCapinMil <= input$MarketCap[2])
allviz <- allviz[1:35,]
})

output$visplot <- renderPlot({

allviztip <- function(x) { if(is.null(x))return(NULL) 
  row <- allviz[allviz$id == x$id,c(1,4,8,10,11,12,13)]
  paste0(names(row),":",format(row),"</div>",collapse="<br />")}

reactviz() %>% ggvis(x=~PriceBook,y=~DivYield,key:=~id,size=~MarketCapinMil,shape=~PayoutCat,fill=~PriceSales) %>%
  layer_points() %>% add_tooltip(allviztip,"click") %>% add_axis('x', title='Price/Book Ratio',title_offset=60,properties=axis_props(labels=list(fontSize=12), title=list(fontSize=18))) %>% 
  add_axis("y", title = "Dividend Yield",title_offset=50,properties=axis_props(labels=list(fontSize=12), title=list(fontSize=18))) %>% 
  add_legend(scales="shape", title="Payout Ratio Category") %>% 
  add_legend(scales="fill", title="Price/Sales Ratio", properties = legend_props(legend = list(y = 100))) %>%
  add_legend(scales="size", title="Market Cap",values=c(1,25,50,100,500,1000,5000,50000,100000,300000),properties = legend_props(legend = list(y = 200))) %>% 
  set_options(duration = 0,height="auto",width="auto") %>%
  scale_numeric(property="fill",range=c("lightblue","darkblue")) %>%
  bind_shiny("visplot","visplot_ui") 

})

output$stockdata <- renderTable({

tableviz <- filter(final, DivYield >= input$Yield[1])
tableviz <- filter(tableviz, DivYield <= input$Yield[2])
tableviz <- filter(tableviz, PAYOUTRATIO >= input$PayoutRatio[1])
tableviz <- filter(tableviz, PAYOUTRATIO <= input$PayoutRatio[2])
tableviz <- filter(tableviz, PriceSales >= input$PriceSales[1])
tableviz <- filter(tableviz, PriceSales <= input$PriceSales[2])
tableviz <- filter(tableviz, MarketCapinMil >= input$MarketCap[1])
tableviz <- filter(tableviz, MarketCapinMil <= input$MarketCap[2])
tableviz


})



})

Hier ist mein ui.R Code:

library(shiny)
library(ggvis)

# Define UI for application that draws a histogram
shinyUI(fluidPage(

  # Application title
  titlePanel("Visual Stock Screener"),

  # Sidebar with a slider input for the number of bins
  sidebarLayout(
    sidebarPanel(
      sliderInput("MarketCap",
                  "Market Capitalization (in Tens of Millions)",
                  min = 1,
                  max = 60000,
                  value = c(100,30000)),

      sliderInput("Yield",
                  "Dividend Yield:",
                  min = 0,
                  max = 1,
                  value = c(.04,.5)),

      sliderInput("PayoutRatio",
                  "Payout Rato:",
                  min = 0,
                  max = 5,
                  value = c(0,.5)),


      sliderInput("PriceSales",
                  "Price/Sales Ratio:",
                  min = 0,
                  max = 25,
                  value = c(0,7)),


      sliderInput("PriceBook",
                  "Price/Book Ratio:",
                  min = 0,
                  max = 30,
                  value = c(0,4))

    ),

    # Show a plot of the generated distribution
    mainPanel(
      tabsetPanel(type="tab",
                  tabPanel("Plot",ggvisOutput("visplot"),uiOutput("visplot_ui")),
                  tabPanel("Data",tableOutput("stockdata")),
                  tabPanel("Documentation",includeHTML("screener-documentation.html"))
                  )


  )
)))

Überlegen Sie, was ich falsch mache und warum meine Visualisierung nicht angezeigt wird?

Antworten auf die Frage(0)

Ihre Antwort auf die Frage