0
私はラップトップでRStudioを実行している作業中の光沢のあるアプリケーションとubuntuの光沢のあるサーバーとの間で許可の問題に遭遇していると思います。イメージをshiny-server上のShinyを通してxlsxドキュメントに埋め込む
このサンプルアプリケーションは、xlsxドキュメントに画像を書き込んで、xlsxをダウンロードできるようにします。これは、光沢のあるサーバーではなく、ローカルで光っているrstudioで動作します。私は一時的に安全な方法でpngを書いて光沢のあるサーバで正式なxlsxに書き込む方法があると推測しています。
はserver.R
library(shiny);library(openxlsx);library(ggplot2)
shinyServer(function(input, output) {
output$downloadReport <- downloadHandler(
filename = "test.xlsx",
content = function(file){
wb <- createWorkbook(paste0(Sys.time(), ".xlsx"))
my_plot <- ggplot(mtcars) + geom_line(aes(x = cyl, y = gear))
worksheet_name <- "ggplot"
addWorksheet(wb, worksheet_name)
png("plot.png", width=1024, height=768, units="px", res=144)
print(my_plot)
dev.off()
insertImage(wb, worksheet_name, "plot.png", width=11.18, height=7.82, units="in")
saveWorkbook(wb, file, overwrite = TRUE)
})
})
ui.R
library(shiny)
shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
helpText(),
downloadButton('downloadReport')),
mainPanel()
))
)
エラーメッセージが表示されますか? tempdir()を使用すると、一時的なイメージを保存する保存場所を取得できます。ありがとう。 –
ありがとう。 tempdirは私がこの問題をどのように解決したかです。 – cylondude