Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将rmarkdown报告与shinyapps链接以导出R中的webapp内容?_R_Web Applications_R Markdown_Shiny - Fatal编程技术网

如何将rmarkdown报告与shinyapps链接以导出R中的webapp内容?

如何将rmarkdown报告与shinyapps链接以导出R中的webapp内容?,r,web-applications,r-markdown,shiny,R,Web Applications,R Markdown,Shiny,我正在尝试构建一个带有Shining in R的webapp,它通过两个表、一个动态图和一个图像来显示不同指标的值。结果就像是列表中所选项目的情况介绍,我希望捕获结果并提供下载屏幕上显示内容的可能性(表格、图表和图像) 我发现我可以通过在Rmarkdown中生成一个报告并使用downloadHandler导出它来实现这一点,如下示例()。据我所知,在服务器中,output$downloadReport根据先前存储在与ui.R和server.R相同目录中的报告模板创建由文件名和内容组成的对象,如下

我正在尝试构建一个带有Shining in R的webapp,它通过两个表、一个动态图和一个图像来显示不同指标的值。结果就像是列表中所选项目的情况介绍,我希望捕获结果并提供下载屏幕上显示内容的可能性(表格、图表和图像)

我发现我可以通过在Rmarkdown中生成一个报告并使用downloadHandler导出它来实现这一点,如下示例()。据我所知,在服务器中,output$downloadReport根据先前存储在与ui.R和server.R相同目录中的报告模板创建由文件名和内容组成的对象,如下所示:

 #Output report
 output$downloadReport <- downloadHandler(
  filename = function() {
   paste(input$City_id,'factsheet', sep = '.', switch(
    input$format, PDF = 'pdf', HTML = 'html', Word = 'docx'
  ))
 },

  content = function(file) {
   src <- normalizePath('report.Rmd')
   return(src)

   # temporarily switch to the temp dir, in case you do not have write
   # permission to the current working directory
   owd <- setwd(tempdir())
   on.exit(setwd(owd))
   file.copy(src, 'report.Rmd')

   library(rmarkdown)
   out <- render('report.Rmd', switch(
     input$format,
     PDF = pdf_document(), HTML = html_document(), Word = word_document()
   ))
   file.rename(out, file)
  }
 )
我得到一个非信息性错误:

打开文件时出错:2
读取错误:6

任何关于正在发生的事情的提示/线索都是非常受欢迎的

非常感谢,, 拉克尔

啊,我的会话信息:

> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Spanish_Spain.1252  LC_CTYPE=Spanish_Spain.1252   
[3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C                  
[5] LC_TIME=Spanish_Spain.1252    

attached base packages:
[1] splines   stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rmarkdown_0.8.1   shiny_0.12.2      rsconnect_0.4.1.7 rCharts_0.4.5    
[5] doBy_4.5-13       survival_2.37-7   foreign_0.8-66   

loaded via a namespace (and not attached):
 [1] digest_0.6.8     evaluate_0.8     formatR_1.2.1    grid_3.1.1      
 [5] htmltools_0.2.6  httpuv_1.3.3     jsonlite_0.9.17  knitr_1.11      
 [9] lattice_0.20-29  magrittr_1.5     MASS_7.3-33      Matrix_1.1-4    
[13] mime_0.4         packrat_0.4.5    plyr_1.8.3       R6_2.1.1        
[17] Rcpp_0.12.1      RJSONIO_1.3-0    rstudio_0.98.977 rstudioapi_0.3.1
[21] stringi_1.0-1    stringr_1.0.0    tools_3.1.1      whisker_0.3-2   
[25] xtable_1.7-4     yaml_2.1.13   

我遇到了类似的情况,也尝试了
downloadHandler
,但我无法让它工作,所以我所做的是:


  • 在服务器代码块中,将生成的绘图、data.frames等放在全局环境中,如下所示:
    plot1Did您得到解决方案了吗?您看过这篇文章了吗:?
    
    > sessionInfo()
    R version 3.1.1 (2014-07-10)
    Platform: x86_64-w64-mingw32/x64 (64-bit)
    
    locale:
    [1] LC_COLLATE=Spanish_Spain.1252  LC_CTYPE=Spanish_Spain.1252   
    [3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C                  
    [5] LC_TIME=Spanish_Spain.1252    
    
    attached base packages:
    [1] splines   stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] rmarkdown_0.8.1   shiny_0.12.2      rsconnect_0.4.1.7 rCharts_0.4.5    
    [5] doBy_4.5-13       survival_2.37-7   foreign_0.8-66   
    
    loaded via a namespace (and not attached):
     [1] digest_0.6.8     evaluate_0.8     formatR_1.2.1    grid_3.1.1      
     [5] htmltools_0.2.6  httpuv_1.3.3     jsonlite_0.9.17  knitr_1.11      
     [9] lattice_0.20-29  magrittr_1.5     MASS_7.3-33      Matrix_1.1-4    
    [13] mime_0.4         packrat_0.4.5    plyr_1.8.3       R6_2.1.1        
    [17] Rcpp_0.12.1      RJSONIO_1.3-0    rstudio_0.98.977 rstudioapi_0.3.1
    [21] stringi_1.0-1    stringr_1.0.0    tools_3.1.1      whisker_0.3-2   
    [25] xtable_1.7-4     yaml_2.1.13