rhandsontable中的输入
嗨,我想从rhansontable输入,它在shiny中。 但是,当列的单元格中充满NA时,无法编辑这些单元格。 这些问题可以解决吗?谢谢rhandsontable中的输入,r,shiny,rhandsontable,R,Shiny,Rhandsontable,嗨,我想从rhansontable输入,它在shiny中。 但是,当列的单元格中充满NA时,无法编辑这些单元格。 这些问题可以解决吗?谢谢 而且当我像这样改变数据类型时 output$hot=renderHandsonTable(rhandsontable(DF,readOnly=F)%%>%hot\u col(col=“Amount”,type=“numeric”) 可以编辑单元格中的值。但是,当我使用'DF=hot_to_r(input$hot)'时,这些值似乎没有保存在DF中。根据链接,
而且当我像这样改变数据类型时
output$hot=renderHandsonTable(rhandsontable(DF,readOnly=F)%%>%hot\u col(col=“Amount”,type=“numeric”)
可以编辑单元格中的值。但是,当我使用'DF=hot_to_r(input$hot)'时,这些值似乎没有保存在DF中。根据链接,您必须将NA转换为字符。所以你需要这样做:
library(shiny)
library(rhandsontable)
ui = shinyUI(fluidPage(
fluidRow(wellPanel(
rHandsontableOutput("hot"),
actionButton(inputId="enter",label="enter")
))
))
server=function(input,output){
DF=data.frame(Code=c(1,2,3),Amount=c(NA,NA,NA))
output$hot=renderRHandsontable(rhandsontable(DF,readOnly=F))
observeEvent(input$enter, {
DF=hot_to_r(input$hot)
print(DF)
})
}
shinyApp(ui = ui, server = server)
将此添加到DF
server=function(input,output){
DF=data.frame(Code=c(1,2,3),Amount=as.character(c(NA,NA,NA)))
output$hot=renderRHandsontable(rhandsontable(DF, readOnly = FALSE) %>%
hot_col("Amount", type = "numeric"))
observeEvent(input$enter, {
DF=hot_to_r(input$hot)
print(DF)
})
}
DF=data.frame(code=c(1,2,3),Amount=c(NA,NA,NA))
DF[is.na(DF)]否,我希望单元格在视图中保持为空。但我希望能够编辑单元格~将其更改为字符将仍然在视图中显示空单元格,只有当您尝试编辑单元格时,它才会像前一种情况一样显示为na。
DF=data.frame(Code=c(1,2,3),Amount=c(NA,NA,NA))
DF[is.na(DF)] <- ""