Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在R中编辑DataTable的特定列_R_Datatable_Multiple Columns_Edit - Fatal编程技术网

在R中编辑DataTable的特定列

在R中编辑DataTable的特定列,r,datatable,multiple-columns,edit,R,Datatable,Multiple Columns,Edit,我试图使用editable=TRUE来编辑r中的数据表。 但是,我只想编辑表中的某些特定列,而不是所有列。可能吗? 我使用的代码是: library(shiny) library(DT) ui <- fluidPage( DT::dataTableOutput('population_table'), textOutput("text") ) server <- function(input, output, session) { data = head(iris) y <-

我试图使用editable=TRUE来编辑r中的数据表。 但是,我只想编辑表中的某些特定列,而不是所有列。可能吗? 我使用的代码是:

library(shiny)
library(DT)

ui <- fluidPage(
DT::dataTableOutput('population_table'),
textOutput("text")
)
server <- function(input, output, session) {
data = head(iris)
y <- reactive({
input$population_table_cell_edit
data
})
output$population_table = DT::renderDataTable(data, selection = 'none', 
editable = TRUE)

proxy = dataTableProxy('population_table')
observeEvent(input$population_table_cell_edit, {
info = input$population_table_cell_edit
str(info) #print 
i = info$row
j = info$col
v = info$value
data[i, j] <<- DT::coerceValue(v, data[i, j])
replaceData(proxy, data, resetPaging = FALSE)
})
output$text <- renderText({
y()[1, 1]
})
}
shinyApp(ui,server)
库(闪亮)
图书馆(DT)

ui可能有点晚了,但我尝试了同样的方法,只通过使用if语句找到了解决问题的方法,例如,如果您只想更改第3列:

if(j == 3){
    data[i, j] <<- DT::coerceValue(v, data[i, j])
    replaceData(proxy, data, resetPaging = FALSE)
}else{}
if(j==3){
数据[i,j]