반짝 이는 애플 리케이션에 새로운 도움이 필요합니다. 파일을 업로드하고 반짝이는 앱에서 탁상용 출력을 생성하는 데는 도움이 필요하지만 pdf로 플롯을 다운로드 할 수는 없습니다. 형식 여기 내 코드PDF 파일을 다운로드 한 후 반짝이는 앱을 사용하여 PDF 플롯을 다운로드
library(shiny)
library(openxlsx)
library(lattice)
runApp(
list(
ui = fluidPage(
titlePanel("plots"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Choose xlsx file',
accept = c(".xlsx")),
tags$hr(),
downloadButton('down',"download plot")
),
mainPanel(
tableOutput('contents'),
plotOutput('plot'))
)
),
server = function(input, output){
output$contents <- renderTable({
inFile <- input$file1
if(is.null(inFile))
return(NULL)
else
read.xlsx(inFile$datapath)
})
plotInput <- reactive({
df <- input$file1
xyplot(df[,2]~df[,1],df(),xlim=c(0,10),ylim=c(0,100),type = "b")
})
output$plot <- renderPlot({
print(plotInput())
})
output$down <- downloadHandler(
filename = function(){paste("plot",".pdf",sep=".") },
content = function(file) {
pdf(file)
xyplot(df[,2]~df[,1],df(),xlim=c(0,10),ylim=c(0,100),type = "b")
dev.off()
}
)
}
)
)
시도가 오류 중 하나가 우리가 기반으로 PDF 파일에 고유 한 개별 플롯을 인쇄 할 수 있습니다 –