我正在构建一个利用dplyr和ggvis的闪亮应用程序。我能够启动应用程序,但我收到一条错误消息:
if中的错误(标记$ name%in%c(" area"," base"," br"," col" ,"命令","嵌入",: 参数长度为零
这是我的 ui.R :
`library(shiny)
library("ggvis")
shinyUI(fluidPage(
titlePanel("Visual Stock Screener"),
sidebarLayout(
sidebarPanel(
numericInput("MinMarketCap",
"Min Market Cap (in Tens of Millions)",
value = 10,
min = 1,
max = 60000),
numericInput("MaxMarketCap",
"Max Market Cap (in Tens of Millions)",
value = 5000,
min = 1,
max = 60000),
numericInput("MinDivYield",
"Min Div Yield:",
value = 0.04,
min = 0,
max = 1),
numericInput("MaxDivYield",
"Max Div Yield:",
value = 0.14,
min = 0,
max = 1),
numericInput("MinPayoutRatio",
"Min Payout Ratio:",
value = 0,
min = 0),
numericInput("MaxPayoutRatio",
"Max Payout Ratio:",
value = 0.4,
min = 0),
numericInput("MinPriceBook",
"Min Price/Book Ratio:",
value = 0,
min = 0),
numericInput("MaxPriceBook",
"Max Price/Book Ratio:",
value = 3,
min = 0),
numericInput("MinPriceSales",
"Min Price/Sales Ratio:",
value = 0,
min = 0),
numericInput("MaxPriceSales",
"Max Price/Sales Ratio:",
value = 7,
min = 0)
),
mainPanel(
tabsetPanel(type="tab",
tabPanel("Plot",ggvisOutput("visplot"),uiOutput("visplot_ui"))
)
)
)))`
这是我的 server.R:
`library(shiny)
library("ggvis")
library(dplyr)
#import file created by screener.R
final <- read.csv("final.csv")
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
output$visplot_ui <- renderUI({
allviz <- na.omit(final)
allviz <- filter(allviz, DivYield >= input$MinDivYield)
allviz <- filter(allviz, DivYield <= input$MaxDivYield)
allviz <- filter(allviz, PAYOUTRATIO >= input$MinPayoutRatio)
allviz <- filter(allviz, PAYOUTRATIO <= input$MaxPayoutRatio)
allviz <- filter(allviz, PriceBook >= input$MinPriceBook)
allviz <- filter(allviz, PriceBook <= input$MaxPriceBook)
allviz <- filter(allviz, PriceSales >= input$MinPriceSales)
allviz <- filter(allviz, PriceSales <= input$MaxPriceSales)
allviz <- filter(allviz, MarketCapinMil >= input$MinMarketCap)
allviz <- filter(allviz, MarketCapinMil <= input$MaxMarketCap)
allviz$id <- 1:nrow(allviz)
allviztip <- function(x) { if(is.null(x))return(NULL)
row <- allviz[allviz$id == x$id,c(1,4,7,8,9,10)]
paste0(names(row),":",format(row)," </div>",collapse="<br />")}
allviz[1:20,] %>% ggvis(x=~PriceBook,y=~DivYield,key:=~id,size=~MarketCap,shape=~PayoutCat,fill=~PriceSales) %>%
layer_points() %>% add_tooltip(allviztip,"hover") %>% bind_shiny("visplot","visplot_ui")
})
})
`
我已经完成了之前与此问题相关的stackoverflow问题,并且可以确认一些常见原因并非如此:
所以我怀疑R用于呈现HTML的函数之一存在某种类型的问题,这反过来让我相信ui.R中存在某种类型的问题。但除此之外我感到沮丧和困难.....任何想法?
答案 0 :(得分:0)
我有完全相同的错误,尽管根本没有使用ggvis。
我在代码和我的代码之间寻找了产生相同错误的常见功能。
我想,问题是您使用的是带有uiOutput的动态界面,而renderUI()
似乎没有设置任何输出元素。
我不明白shiny_bind()
的作用是什么,但您可以尝试在p("this is a test")
的末尾添加一个简单的html输出,renderUI()
。