如何在R语言中实现数据表的内联编辑
我正在运行一个R闪亮的web应用程序。我使用datatables来显示数据。但是我想要表格单元格的内联编辑。我不能那样做。有人能指引我吗 这是我的密码如何在R语言中实现数据表的内联编辑,r,datatable,shiny,R,Datatable,Shiny,我正在运行一个R闪亮的web应用程序。我使用datatables来显示数据。但是我想要表格单元格的内联编辑。我不能那样做。有人能指引我吗 这是我的密码 # UI.R fluidRow( column(4,dataTableOutput("numericalBin")), column(8,h1("numericalBin_Chart"))) ) #Server.R 输出$numericalBin除了@dracodoc提出的DT原型外,另一个选项是使用 编
# UI.R
fluidRow(
column(4,dataTableOutput("numericalBin")),
column(8,h1("numericalBin_Chart")))
)
#Server.R
输出$numericalBin除了@dracodoc提出的DT原型外,另一个选项是使用
编辑:根据@hveig和@Munawir的评论,现附上一段工作示例代码(改编自):
库(闪亮)
图书馆(rhandsontable)
shinyApp(
新余(
fluidRow(
rHandsontableOutput(“热”)
)),
shinyServer(功能(输入、输出、会话){
值=反应值()
数据=无功({
如果(!为.null(输入$hot)){
DF=热到热(输入$hot)
}否则{
if(为.null(值[[“DF”]]))
DF=mtcars
其他的
DF=值[[“DF”]]
}
值[[“DF”]]=DF
DF
})
输出$hot这一个确实很有趣,我想听听其他人会怎么做。但现在我会通过bsModal使用shinyBS库和它的modals来链接将弹出的依赖项,并做你想做的事情…有一个DT编辑器的原型
# Server.R
output$numericalBin <- renderDataTable({
mtcars
},options = list(
lengthChange=FALSE,
searching=FALSE,
autoWidth=TRUE,
paging=FALSE
))
library(shiny)
library(rhandsontable)
shinyApp(
shinyUI(
fluidRow(
rHandsontableOutput("hot")
)),
shinyServer(function(input, output, session) {
values = reactiveValues()
data = reactive({
if (!is.null(input$hot)) {
DF = hot_to_r(input$hot)
} else {
if (is.null(values[["DF"]]))
DF = mtcars
else
DF = values[["DF"]]
}
values[["DF"]] = DF
DF
})
output$hot <- renderRHandsontable({
DF = data()
if (!is.null(DF))
rhandsontable(DF, stretchH = "all")
})
})
)