【发布时间】:2019-07-02 11:43:48
【问题描述】:
shinyApp(
ui = fluidPage(
DTOutput('x1')
),
server = function(input, output, session) {
x = iris
output$x1 = renderDT(x, selection = 'none', editable = list(target = 'row', disable = list(columns=c(1,3,4))))
proxy = dataTableProxy('x1')
observeEvent(input$x1_cell_edit, {
info = input$x1_cell_edit
str(info)
i = info$row
j = info$col
v = info$value
x[i, j] <<- DT::coerceValue(v, x[i, j])
replaceData(proxy, x, resetPaging = FALSE) # important
})
}
)
我收到以下警告:
Warning in DT::coerceValue(v, x[i, j]) :
The data type is not supported: data.frame
Warning: Error in [[: attempt to select less than one element in integerOneIndex
如何确保 coerceValue 正在编辑和保存我的新输入?
【问题讨论】:
-
使用
target = "cell"和j = info$col + 1。 -
target = "cell" 为我工作,谢谢!
-
target = "cell" 是正确的,但是 j = info$col + 1 是不正确的。将其保留为 j = info$col,因为 DT 会忽略行名列。