R 数据表只允许用户编辑某些列
一个简单的应用程序:R 数据表只允许用户编辑某些列,r,shiny,dt,R,Shiny,Dt,一个简单的应用程序: # # This is a Shiny web application. You can run the application by clicking # the 'Run App' button above. # # Find out more about building applications with Shiny here: # # http://shiny.rstudio.com/ # library(shiny) # Define UI for a
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("blah"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(),
# Show a plot of the generated distribution
mainPanel(
DT::DTOutput('ex_df')
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$ex_df <- DT::renderDT(data.frame(
x = 1:10,
y = 1,
z = 11:20
),
selection = 'none', editable = 'cell', server = TRUE, rownames = FALSE,
list(target = 'cell', disable = list(columns = c(1,2)))
)
}
# Run the application
shinyApp(ui = ui, server = server)
#
#这是一个闪亮的web应用程序。您可以通过单击来运行应用程序
#上面的“运行应用程序”按钮。
#
#在此处了解有关使用Shining构建应用程序的更多信息:
#
# http://shiny.rstudio.com/
#
图书馆(闪亮)
#为绘制直方图的应用程序定义UI
ui根据DT::datatable()
的文档,可编辑的参数的结构应该不同:
此参数也可以是表单列表的列表(target=target,
禁用=列表(列=索引)),其中目标可以是单元格、行、,
列或全部,而索引是列索引的整数向量
尝试editable=list(target=“column”,disable=list(columns=c(1,2))
根据DT::datatable()
的文档,editable
参数的结构应该不同:
此参数也可以是表单列表的列表(target=target,
禁用=列表(列=索引)),其中目标可以是单元格、行、,
列或全部,而索引是列索引的整数向量
请尝试editable=list(target=“column”,disable=list(columns=c(1,2))
谢谢我试过了,但所有列仍显示为editable谢谢我试过了,但所有列仍显示为editable