Я могу использовать данные "df <- df_products_upload ()" для построения графика, но после того, как я отфильтровал их и rbind к новому набору данных. (Поскольку я хочу добавить новый столбец на основе разных сезонов и дневных условий, поэтому я используется «фильтр», а не «группировать по».) Но я получаю это предупреждение: ошибка в: Результат должен иметь длину 35040, а не 0. </p>
Пожалуйста, помогите мне. Большое вам спасибо.
df_plot<- reactive({
df <- df_products_upload()
OutputPower <- input$OutputPower
Unit <- input$Unit
BatteryOutput <- OutputPower*Unit
############################################
# Add a new column for Save energy amont#
f1 <- filter(df,df$month ==1)
d1<-(max(f1$EnergyUsage_KW)-BatteryOutput)
f1 <- transform(f1, NewC = ifelse(f1$EnergyUsage_KW>d1, f1$EnergyUsage_KW-d1, 0))
f2 <- filter(df,df$month ==2)
d2<-(max(f2$EnergyUsage_KW)-BatteryOutput)
f2 <- transform(f2, NewC = ifelse(f2$EnergyUsage_KW>d2, f2$EnergyUsage_KW-d2, 0))
f3 <- filter(df,df$month ==3)
d3<-(max(f3$EnergyUsage_KW)-BatteryOutput)
f3 <- transform(f3, NewC = ifelse(f3$EnergyUsage_KW>d3, f3$EnergyUsage_KW-d3, 0))
f4 <- filter(df,df$month ==4)
d4<-(max(f4$EnergyUsage_KW)-BatteryOutput)
f4 <- transform(f4, NewC = ifelse(f4$EnergyUsage_KW>d4, f4$EnergyUsage_KW-d4, 0))
f5 <- filter(df,df$month ==5)
d5<-(max(f5$EnergyUsage_KW)-BatteryOutput)
f5 <- transform(f5, NewC = ifelse(f5$EnergyUsage_KW>d5, f5$EnergyUsage_KW-d5, 0))
f6 <- filter(df,df$month ==6)
d6<-(max(f6$EnergyUsage_KW)-BatteryOutput)
f6 <- transform(f6, NewC = ifelse(f6$EnergyUsage_KW>d6, f6$EnergyUsage_KW-d6, 0))
ff1 <- filter(df,df$month ==7)
dd1<-(max(ff1$EnergyUsage_KW)-BatteryOutput)
ff1 <- transform(ff1, NewC = ifelse(ff1$EnergyUsage_KW>dd1, ff1$EnergyUsage_KW-dd1, 0))
ff2 <- filter(df,df$month ==8)
dd2<-(max(ff2$EnergyUsage_KW)-BatteryOutput)
ff2 <- transform(ff2, NewC = ifelse(ff2$EnergyUsage_KW>dd2, ff2$EnergyUsage_KW-dd2, 0))
ff3 <- filter(df,df$month ==9)
dd3<-(max(ff3$EnergyUsage_KW)-BatteryOutput)
ff3 <- transform(ff3, NewC = ifelse(ff3$EnergyUsage_KW>dd3, ff3$EnergyUsage_KW-dd3, 0))
ff4 <- filter(df,df$month ==10)
dd4<-(max(ff4$EnergyUsage_KW)-BatteryOutput)
ff4 <- transform(ff4, NewC = ifelse(ff4$EnergyUsage_KW>dd4, ff4$EnergyUsage_KW-dd4, 0))
ff5 <- filter(df,df$month ==11)
dd5<-(max(ff5$EnergyUsage_KW)-BatteryOutput)
ff5 <- transform(ff5, NewC = ifelse(ff5$EnergyUsage_KW>dd5, ff5$EnergyUsage_KW-dd5, 0))
ff6 <- filter(df,df$month ==12)
dd6<-(max(ff6$EnergyUsage_KW)-BatteryOutput)
ff6 <- transform(ff6, NewC = ifelse(ff6$EnergyUsage_KW>dd6, ff6$EnergyUsage_KW-dd6, 0))
dfPlot<-rbind(f1,f2,f2,f3,f4,f5,f6,ff1,ff2,ff3,ff4,ff5,ff6)
dfPlot })
output$plot6 <- renderPlot({
dfPlot <- df_plot()
p99 <- ggplot() + geom_line(aes(y = NewC , x = Date),
data = dfPlot, stat="identity")
p99
})