0
저는 랩톱의 RStudio와 우분투의 반짝이는 서버 사이에서 권한있는 문제를 겪고 있다고 생각합니다.반짝이는 서버에서 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