要求是创建一个pdf报告,用户可以在其中选择每个图,单击复制并可以将图像插入到powerpoint中。 我用闪亮的示例应用程序用R创建了这样的pdf报告:
https://shiny.rstudio.com/articles/generating-reports.html (请参见下面的代码)
$(document).resize(function(e){
if(window.width() <= 320)
{
$('.slick').slick({
slidesToShow: 2,
slidesToScroll: 1,
});
}
else if(window.width() <= 480)
{
$('.slick').slick({
slidesToShow: 2,
slidesToScroll: 1,
});
}
else if(window.width() <= 542)
{
$('.slick').slick({
slidesToShow: 3,
slidesToScroll: 1,
});
}
else if(window.width() <= 768)
{
$('.slick').slick({
slidesToShow: 4,
slidesToScroll: 1,
});
}
else{
$('.slick').slick({
slidesToShow: 5,
slidesToScroll: 1,
});
}
});
Rmd:
shinyApp(
ui = fluidPage(
sliderInput("slider", "Slider", 1, 100, 50),
downloadButton("report", "Generate report")
),
server = function(input, output) {
output$report <- downloadHandler(
# For PDF output, change this to "report.pdf"
filename = "report.pdf",
content = function(file) {
# Copy the report file to a temporary directory before processing it, in
# case we don't have write permissions to the current working dir (which
# can happen when deployed).
tempReport <- file.path(tempdir(), "report.Rmd")
file.copy("report.Rmd", tempReport, overwrite = TRUE)
# Set up parameters to pass to Rmd document
params <- list(n = input$slider)
# Knit the document, passing in the `params` list, and eval it in a
# child of the global environment (this isolates the code in the document
# from the code in this app).
rmarkdown::render(tempReport, output_file = file,
params = params,
envir = new.env(parent = globalenv())
)
}
)
}
)