问题描述
B C D E F G H
Date Time Kwh $/KwCost Hours/MonthsCost/Kwh
2021-01-01 0:15 0.69 $0.00 0 months $0.15
2021-01-01 0:30 0.51 $0.00 0 11-12,1-5 $0.05
01/08/21 0:45 0.3 $0.00 0 hours
2021-01-01 1:00 0.76 $0.00 0 06-08,15-20 ```
规则:如果月份#在g3中,小时#在g5中,则$h$2。
我正在使用
=iF (LSTOR(MONTH(c2),$h$3)= MONTH(c2)) and (LSTOR(HOUR(d2),$h$5)=HOUR(d2)) then $i$2 else $i$3
但是我得到了
509 Missing operator 运算符缺失,例如“=2(3+4) *”, 其中缺少“2”和“(”之间的运算符。)
谁能告诉我错误在哪里?
解决方法
考虑到此版本的 ListOK 插件中的所有函数都使用正整数(零除外),您必须指定 G5 移位范围内的值,
library(shiny)
library(DT)
library(shinyWidgets)
library(tidyverse)
# create master dataframe
dat_total <- tibble(ID_1 = 1:10,names = letters[1:10],ID_2 = 11:20,names_2 = LETTERS[c(3:5,1,2,6:8,10,9)])
shinyApp(
ui = fluidPage(
title = 'Radio button and a dropdown manue ',sliderInput("n_rows_table","Number of rows:",min = 0,max = 10,value = 5),actionBttn(
inputId = "button_1",label = "Make tables",size = "sm",color = "warning"
),DT::dataTableOutput("mytable"),actionBttn(
inputId = "button_2",label = "Process",color = "success"),DT::dataTableOutput("table2")),server = function(input,output,session) {
# set up reactive values
dat_left <- reactiveValues(data=NULL)
dat_right <- reactiveValues(data=NULL)
dat_joined <- reactiveValues(data=NULL)
# create reactive daraframe
dat <- eventReactive(input$button_1,{
dat_total[1:input$n_rows_table,] %>%
rowid_to_column()})
# Split the data into a right and a left set
observe({
dat_left$data <- dat() %>%
select(rowid,ID_1,names)
})
observe({
dat_right$data <- dat() %>%
select(rowid,ID_2,names_2,ID_1)
})
# join these again
# This is needed because my actual app will
# be used to manually match 2 datasets
observe({
if (is.null( dat_right$data )) {
NULL
}else{
dat_joined$data <- left_join(dat_left$data,dat_right$data,by = "rowid")
}
})
# Print the the datasets
output$mytable <- renderDT({
datatable(dat_joined$data,rownames = F,editable = "cell")
})
# I want to make a copy of the dat_joined$data dataset into dat$mydf
# none of these function as expected
#mydf <- reactiveValues(data=isolate(dat_joined$data))
#mydf <- reactiveValues(data=local(dat_joined$data))
#mydf <- reactiveValues(data=dat_joined$data)
#mydf <- reactiveValues(data=NULL)
# This works,but only saves the cells to w
mydf <- reactiveValues(data=matrix(NA,nrow=10,ncol = 5))
# Ideally the computation only happens when this both an edit is made
# and the button is pressed (now I need to press it between every edit)
# validate_event <- reactive({
# req(input$mytable_cell_edit) & req(input$button_2)
# })
#observeEvent(input$button_2validate_event(),{ DOes not work
observeEvent(input$button_2,{
info = input$mytable_cell_edit
str(info)
i = info$row
j = info$col
v = info$value
mydf$data[i,j] <- DT::coerceValue(v,mydf$data[i,j])
})
# print
output[["table2"]] <- renderDT({
datatable(mydf$data)
})
}
)
而不是 {{1} }.在这种情况下,公式
7-9,16-21
应该给你想要的结果。