我想让用户看到输入的变化,以直接反映在表上。因此,一旦用户更改了输入low_val
的数值,它就应该反映出表中lower_rate列的更改,并将该值乘以observeEvent
。 input_data <- data.frame(lower_rate = c (.5, .5, .5),
low_val = c(10,11,12),
upper_rate = c(1.5, 1.5, 1.5),
upp_val = c(20,21,22),
stringsAsFactors = FALSE)
ui <- shinyUI(
fluidPage(
titlePanel("Basic DataTable"),
# Create a new row for the table.
fluidRow(
column(12,
numericInput("low", label = h3("lower"), value = 0.5),
numericInput("up", label = h3("Upper"), value = 1.5),
dataTableOutput(outputId="table")
)
)
)
)
server <- shinyServer(function(input, output) {
d <- reactive({
input_data
})
dat <- reactiveValues(dat=NULL)
observe({
dat$dat <- d()
})
output$table <- renderDataTable({
dat$dat
})
})
shinyApp(ui=ui,server=server)```
是否可以解决数字输入更改。
from acumos.session import AcumosSession
from acumos.modeling import Model, List, create_dataframe
from tensorflow.python.keras.models import load_model
# This version tells me : unable to open file: name = 'data/keras/ticketsModel/model.hdf5'
#def classify_ticket(inText: str) -> str:
# current_model = load_model('data/keras/ticketsModel/model.hdf5')
# return current_model.predict(inText)
# This version tells me : NotImplementedError: numpy() is only available when eager execution is enabled.
current_model = load_model('data/keras/ticketsModel/model.hdf5')
def classify_ticket(inText: str) -> str:
return current_model.predict(inText)
model = Model(classify=classify_ticket)
session = AcumosSession()
session.dump(model,'ticket_classification','acumos_out')
答案 0 :(得分:0)
我认为最好在反应性环境renderDataTable
中编辑列值。不需要观察事件。只要您不使用<<-
表示法写入环境,就不会更改原始数据。
library(shiny)
library(data.table)
input_data <- data.frame(lower_rate = c(.5, .5, .5),
low_val = c(10,11,12),
upper_rate = c(1.5, 1.5, 1.5),
upp_val = c(20,21,22),
stringsAsFactors = FALSE)
ui <- shinyUI(
fluidPage(
titlePanel("Basic DataTable"),
# Create a new row for the table.
fluidRow(
column(12,
numericInput("low", label = h3("lower"), value = 0.5),
numericInput("up", label = h3("Upper"), value = 1.5),
dataTableOutput(outputId="table")
)
)
)
)
server <- shinyServer(function(input, output) {
output$table <- renderDataTable({
input_data$lower_rate <- input$low
#it is not clear where you want the multiplied value to end up
input_data$new_val <- input$low*input_data$low_val
data.table(input_data)
})
})
shinyApp(ui=ui,server=server)