Hi all,
I have tried to follow the example use of fileInput in this example [1] to attempt to open a local sqlite database (using Chrome). It seems that after selecting a file with the fileInput widget, the full path of the selected file is not stored. Instead, only the name of the file is stored. The evidence for this is that I the following error message after selecting "test.db" from the browser UI:
> runApp("/Users/arq5x/shiny/")
Listening on port 8100
name size type
1 test.db 16048128
datapath
1 /var/folders/7r/c3r2sn4j3dvg4c62jr1dq8_w0000gn/T//RtmpAk41Pt/e23a2c42561fcb0d044d05f5/0
Error in path.expand(dbname) : invalid 'path' argument
Error in path.expand(dbname) : invalid 'path' argument
Am I missing something obvious? I know the server code can work since it works fine when I hard-code a full path to a file in the dbConnect statement instead of using input$db
Code below:
ui.R
===
library(shiny)
# Define UI for dataset viewer application
shinyUI(pageWithSidebar(
headerPanel("Gemini"),
sidebarPanel(
fileInput("db", "gemini database", multiple=FALSE),
checkboxInput("lof", "Loss of function")
),
mainPanel(
tableOutput("view")
)
))
server.R
=======
library(shiny)
library(RSQLite)
# Define server logic required to summarize and view the selected dataset
shinyServer(function(input, output) {
output$view <- reactiveTable(function() {
if (! is.null(input$db)) {
print(input$db)
con <- dbConnect(dbDriver("SQLite"),
dbname = input$db)
query = paste("select ", "chrom, start, end",
" from variants limit 10")
df = dbGetQuery(con, query)
df
}
})
})