1
我想做一個非常簡單的閃亮的應用程序,允許用戶從下拉菜單中選擇圖像文件,然後從Dropbox加載所選的圖像文件並顯示在閃亮應用程序。我正在使用rdrop2軟件包中的drop_get函數,如下所述:https://github.com/karthik/rdrop2。 不幸的是,似乎該文件沒有加載,但它顯示替代文本需要幾秒鐘,所以在後臺發生了一些事情(在控制檯中沒有錯誤消息或警告)。我的令牌和Dropbox安裝程序應該可以工作,因爲如果我在閃亮的應用程序之外嘗試它,它會完美地加載文件。從Dropbox加載圖像文件到R Shiny應用程序
道歉代碼是不是100%可重複的令牌包括我個人的Dropbox認證細節...
ui.R
library(shiny)
shinyUI(fluidPage(
titlePanel("My app"),
sidebarLayout(
sidebarPanel(
selectInput("figure",
"Choose figure",
choices = list("file1","file2"),
selected = "file1")
),
mainPanel(
imageOutput("image")
)
)
))
server.R
library(shiny)
library(rdrop2)
token <- readRDS("droptoken.rds")
drop_acc(dtoken = token)
shinyServer(function(input, output) {
reactive({
drop_get(paste(input$figure, '.jpg', sep = ''))
})
output$image <- renderImage({
filename <- paste(input$figure, '.jpg', sep='')
list(src = filename,
alt = paste("Image name:", input$figure))
}, deleteFile = FALSE)
})
您可以嘗試將'reactive'的輸出分配給值(並將其顯示在應用程序中)。只是爲了檢查結果是「真」 –