助けを歓迎します。SQliteデータベースの複数のテーブルで矛盾しています
私は複数のSQliteデータベースとrhandsontableパッケージの両方を使用する光沢のあるアプリを開発しています。私はこのパッケージの使用に関して、オンラインで役立つ資料をたくさん見つけましたが、私は2日間を1つの問題にこだわって欲求不満のレベルにあります。
したがって、以下のスクリプトは、司教区のサーバーとUIを示しています。私はユーザの編集を有効にしたいと思っていました。修正されたテーブル(オンラインでたくさんカバーされています)を安全に扱いたいと思っています。そしてはい私は変更を行う場合、それは安全です。しかし、選択入力によって別のテーブルに移動しようとすると、もう一方のテーブルの内容はすぐにREPLACEDに変更されます。
他のテーブルに影響を与えることなく、変更を独立させたいと思っています。
再度、お手数をおかけします。
downloadTableUI <- function(id) {
ns <- NS(id)
tagList(
sidebarLayout(
sidebarPanel(
selectInput(ns("dataset"), "Choose a dataset:",
choices = dput(as.character(alltables[1: NROW(alltables)]))),
radioButtons(ns("filetype"), "File type:",
choices = c("csv", "tsv")),
dateRangeInput(ns("daterange2"), "Date Filtration",
start = "2017-02-17",
end = "2017-03-07"),
actionButton(ns("saveBtn"), "Save"),
br(),
downloadButton(ns('downloadData'), 'Download File', class = "btn-info")
),
mainPanel(
rHandsontableOutput(ns('tabletest'), width = 730, height = 600)
),
position = c("left")
)
)
}
DownloadTable <- function(input, output, session, pool) {
#select databases
tableChoozer <- reactive({input$dataset})
# dateSelector <- reactive({input$daterange2})
# Initiate the reactive table
p1 <- reactive({
results <- dbGetQuery(pool, paste('select * from ', tableChoozer()))
return (results)
})
Mychanges <- reactive({
observe({
input$saveBtn# update database file each time the button is pressed
if (!is.null(input$tabletest)) {#if there 's a table input
dbWriteTable(pool, tableChoozer(),hot_to_r(input$tabletest), overwrite = TRUE, row.names = FALSE)# overwrite the database
}
})
#THIS IS WHERE I THINK THE PROBLEM IS
if (is.null(input$tabletest)) {
return (p1())
} else if (!identical(p1(), input$tabletest)) {
mytable <- as.data.frame(hot_to_r(input$tabletest))
return (mytable)
}
})
output$tabletest <- renderRHandsontable({
rhandsontable(Mychanges()) %>%
hot_cols(columnSorting = TRUE, highlightCol = TRUE, highlightRow = TRUE,allowRowEdit = FALSE, allowColEdit = FALSE, exportToCsv = TRUE)
})
output$downloadData <- downloadHandler(
filename = function() {
paste("table.csv")
},
content = function(file) {
sep <- switch (input$filetype, "csv" = ",", "tsv" = "\t")
write.table(p1(), file, sep = sep, row.names = FALSE)
}
)
}
私に戻ってくれてありがとう。再現可能なコードを提供しないことで、誰もが自分自身に役立つことができないことに気付きました。その結果、適切な回答があるかどうかをテストすることができます。その結果、https://コードで問題のレポを作成しました。 github.com/BrianMaja/EDSS_table_issue/tree/master/EDSS、私はあなたがそれを支援することができるようにテストするのに役立つと信じています。もう一度ありがとう! – nybre
Gregor de Cillia、ありがとう!! .....それは動作します... ... githubのリンクに解決策を掲載しました – nybre