我有一个与下图相同的数据表,当我单击随机行时,应用程序将崩溃,并收到以下错误消息:
Warning in widgetFunc() :
renderDataTable ignores ... arguments when expr yields a datatable object; see ?renderDataTable
Warning: Unhandled error in observer: (list) object cannot be coerced to type 'logical'
observeEvent(input$responses_rows_selected)
ERROR: [on_request_read] connection reset by peer
我不确定此错误消息的含义。
服务器.r
CreateDefaultRecord <- function() {
mydefault <- CastData(list(id = "0", name = "", used_shiny = FALSE, r_num_years = 4))
return (mydefault)
}
CastData <- function(data) {
datar <- data.frame(name = data["name"],
used_shiny = as.logical(data["used_shiny"]),
r_num_years = as.integer(data["r_num_years"]),
stringsAsFactors = FALSE)
rownames(datar) <- data["id"]
return (datar)
}
UpdateInputs <- function(data, session) {
updateTextInput(session, "id", value = unname(rownames(data)))
updateTextInput(session, "name", value = unname(data["name"]))
updateCheckboxInput(session, "used_shiny", value = as.logical(data["used_shiny"]))
updateSliderInput(session, "r_num_years", value = as.integer(data["r_num_years"]))
}
# Select row in table -> show details in inputs
observeEvent(input$responses_rows_selected, {
if (length(input$responses_rows_selected) > 0) {
data <- ReadData()[input$responses_rows_selected, ]
UpdateInputs(data, session)
}
})
# display table
output$responses <- DT::renderDataTable({
#update after submit is clicked
input$submit
#update after delete is clicked
input$delete
DT::datatable(ReadData(), options = list(pageLength=3),colnames = c('ID' = 1), class = 'cell-border stripe')
}, server = FALSE, selection = "single",
colnames = unname(GetTableMetadata()$fields)[-1]
)