结果长度必须为非零吗? [英] Result must have non-zero length?
本文介绍了结果长度必须为非零吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我被要求为一家公司的实习生做编码项目,但我无法完成。但是我没有得到我想要完成的工作。出现的错误是:
I was asked to do the coding project for a job as an intern in a company but I wasnt able to complete it. However I didn't get the job I wanted to just complete the thing . The error that arrives is:
错误:结果的长度必须为12813,而不是0
Error :Result must have length 12813, not 0
这是我的代码:
library(shiny)
library(dplyr)
stock<-read.csv("thafinal2.0.csv")
ui <- fluidPage(
dateInput(inputId = 'date1',label = 'Start',value = "2017-08-20"),
dateInput(inputId = 'date2',label = 'Stop',value = "2018-08-20"),
tabPanel("stock", DT::dataTableOutput("table")))
server <- function(input, output) {
output$table<-DT::renderDataTable({
stock %>%
filter(stock$date >= "2018-01-05" & stock$date <= "2018-01-03")
stock })}
shinyApp(ui, server)
我要选择范围为
推荐答案
回答戴森。
问题出在代码中:
Answer goes out to Dason. The problem is in code:
filter(stock$date >= "2018-01-05" & stock$date <= "2018-01-03")
您同时过滤的日期晚于 2018-01-05和早于 2018-01-03的这种操作会导致长度为0的空集。
You filter simultanously dates later than "2018-01-05" and earlier than "2018-01-03" this kind of operation results to empty set with length 0.
如果更改为:
filter(stock$date <= "2018-01-05" & stock$date >= "2018-01-03")
应该可以。
这篇关于结果长度必须为非零吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文