Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.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 无法更改已在中向HandContable添加的列_R_Shiny_Shiny Reactivity_Rhandsontable - Fatal编程技术网

R 无法更改已在中向HandContable添加的列

R 无法更改已在中向HandContable添加的列,r,shiny,shiny-reactivity,rhandsontable,R,Shiny,Shiny Reactivity,Rhandsontable,我正在尝试制作一个应用程序,用户可以将列和行添加到一个表中,他们可以使用该表设置规则来对存储在另一个对象中的数据集进行排序 我构建了一个reprex来隔离问题。单击“添加”按钮,用户界面将成功地向表中添加行和列。附加行可以正常工作。但是,无法更改新列中的单元格。您可以输入文本,但不能切换单元格。我仍在学习闪亮的反应性规则,并怀疑问题存在。我试着领养 但是没有用 library(shiny) library(rhandsontable) library(tidyverse) ui <-

我正在尝试制作一个应用程序,用户可以将列和行添加到一个表中,他们可以使用该表设置规则来对存储在另一个对象中的数据集进行排序

我构建了一个reprex来隔离问题。单击“添加”按钮,用户界面将成功地向表中添加行和列。附加行可以正常工作。但是,无法更改新列中的单元格。您可以输入文本,但不能切换单元格。我仍在学习闪亮的反应性规则,并怀疑问题存在。我试着领养

但是没有用

library(shiny)
library(rhandsontable)
library(tidyverse)

ui <- fluidPage(
        actionButton("addRow",
                     "Add"),
        numericInput("rows",
                     "Number of Rows",
                     value = 0, 
                     min = 0),
        numericInput("colAnd",
                     "Number of And Cols",
                     value = 0, 
                     min = 0),
        numericInput("colBut",
                     "Number of But Cols",
                     value = 0, 
                     min = 0),
        rHandsontableOutput("hot")
)

server <- function(input, output) {

df <- reactive({
        tibble(Topic = "Null",
               And = "Null",
               But = "Null")
    })  

df2 <- eventReactive(input$addRow,{

add_row_custom<- function (df, n, add = "null") 
    {
        new <- data.frame(matrix(add, nrow = n, ncol = ncol(df)))
        colnames(new) <- colnames(df)
        rbind(df, new)
}

final <- hot_to_r(input$hot) 
        final %>% 
            add_row_custom(., input$rows ) %>% 
            cbind(., data.frame(matrix("null", 
                                       nrow = nrow(.), 
                                       ncol = input$colAnd + input$colBut)
                                )
                  )

    })

df4 <- reactive({
        if(input$addRow == 0){
            df()
        }else{
            df2()}
    })

output$hot <- renderRHandsontable(rhandsontable(df4()) %>% 
                                          hot_table(highlightRow = T,
                                                    highlightCol = T))
}

# Run the application 
shinyApp(ui = ui, server = server)
库(闪亮)
图书馆(rhandsontable)
图书馆(tidyverse)

ui在我的头撞了几个小时之后,我离开了30分钟,去看rhandsontable文档

长话短说,在rhandsontable函数下添加参数useType=F