У меня есть список тибблов и запасной столик для каждого бриллианта.Должно быть только два столбца (столбцы 3 и 4 - «Открытые позиции»), которые могут редактироваться пользователем.Другие столбцы должны быть исправлены.Это прекрасно работает, если пользователь не добавляет строки.Моя проблема в том, что пользователь может вводить значения только в столбцы 3 и 4, если он добавляет дополнительную строку.Для добавленных вручную строк пользователем вся строка должна быть редактируемой, но для заданных строк редактируемыми должны быть только столбцы 3 и 4.
Заранее спасибо.
library(dplyr)
library(rhandsontable)
library(shiny)
hr <- list(April = tibble(ID = c("1","2","3"),
Job= c("a","b","c"),
`Open Positions Start Of Month`=c("1","1","1"),
`Open Positions End Of Month`=c("1","0","1"),
Applicants=c("20","30","40"),
`First Interviews`=c("3","2","1"),
`Second Interviews`=c("1","1","1"),
Confirmations=c("0","1","0")),
May = tibble(ID = c("1","3","4"),
Job= c("a","c","d"),
`Open Positions Start Of Month`=c("2","1","0"),
`Open Positions End Of Month`=c("0","0","1"),
Applicants=c("10","10","40"),
`First Interviews`=c("2","2","2"),
`Second Interviews`=c("2","2","1"),
Confirmations=c("2","1","0")),
June = tibble(ID = c("4","5","6"),
Job= c("d","e","f"),
`Open Positions Start Of Month`=c("1","1","1"),
`Open Positions End Of Month`=c("1","0","1"),
Applicants=c("10","10","50"),
`First Interviews`=c("4","2","5"),
`Second Interviews`=c("3","1","3"),
Confirmations=c("1","1","3")))
ui <- shinyUI(fluidPage(
titlePanel("Recruiting KPIs"),
selectInput("input_name", "Month:", choices = names(hr), width = '20%'),
mainPanel(
rHandsontableOutput("hot", width = 1200)
)
)
)
server <- 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 = as_tibble(hr[[input$input_name]])
else
DF = values[["DF"]]
}
values[["DF"]] = DF
DF
})
output$hot <- renderRHandsontable({
DF = as_tibble(hr[[input$input_name]])
if (!is.null(DF))
rhandsontable(DF, width = 1600) %>%
hot_col( c("ID", "Open Positions Start Of Month","Open Positions End Of Month", "Applicants", "First Interviews", "Second Interviews", "Confirmations"), valign='htCenter') %>%
hot_col("Job", valign='htLeft' ) %>%
hot_col( c("ID", "Job", "Applicants", "First Interviews", "Second Interviews", "Confirmations"), readOnly = TRUE) %>%
hot_table(highlightCol = TRUE, highlightRow = TRUE) %>% hot_cols(columnSorting = TRUE)
})
})
shinyApp(ui = ui, server = server)