jasdumas / shinyGEO

Gene Expression Omnibus Analysis with Shiny :microscope:
http://jasdumas.com/shinyGEO/
Other
41 stars 47 forks source link

Reproducible research components: report #31

Closed jasdumas closed 7 years ago

jasdumas commented 9 years ago

https://github.com/trestletech/shinyAce#03-knitr

I want to put a demo report section in the current tool that aggregates the graphs and statistical approaches taken through-out the tool to create a PDF report for printing.

Like the example, i'm not sure there is enough room to have the ace editor and the knitr report side-by-side. Possibly vertical stacked or maybe a movable window as seen in the shiny gallery. http://shiny.rstudio.com/gallery/absolutely-positioned-panels.html

jasdumas commented 9 years ago

I'm currently working on improving the Report tab and its components for the expression plot first. I'm getting some (fixable) errors in the aceEditor on launch from the code. I believe it's just structure. I'm also wondering about the code highlighting. Here are two screen shots depicting errors in the code:

screenshot 2015-08-11 14 10 39

screenshot 2015-08-11 14 10 51

jasdumas commented 9 years ago

Not quite responsive but its actually showing up on the application!

report-awesome-exp

jasdumas commented 9 years ago

With the current settings of the Reproducible report, after pressing the download button, and empty window would appear and state the text2dvi was missing. Through trying to knit a regular .Rmd file to PDF I got the following error:

output file: Homework-trial.knit.md

pandoc: pdflatex not found. pdflatex is needed for pdf output. Error: pandoc document conversion failed with error 41 Execution halted

No TeX installation detected (TeX is required to create PDF output). You should install a recommended TeX distribution for your platform:

Windows: MiKTeX (Complete) - http://miktex.org/2.9/setup (NOTE: Be sure to download the Complete rather than Basic installation)

Mac OS X: TexLive 2013 (Full) - http://tug.org/mactex/ (NOTE: Download with Safari rather than Chrome strongly recommended)

Linux: Use system package manager


I will be downloading the suggested MacTex file and seeing the progress of the download afterwards.

gdancik commented 9 years ago

I would keep the report output as HTML instead of a PDF. Not only should that be easier to produce, but a user would be more interested in HTML than PDF, especially if the report is generated within Shiny.

jasdumas commented 9 years ago

Ok great! I agree. I happen to notice this PDF error when I was developing something for school. I have switched it the report to an HTML output but my current output is blank, but error free!

See below:

output$downloadData <- downloadHandler(
filename = function() { 
paste("report", "html", sep=".") 
},
content = function(file) {
src <- normalizePath('report.Rmd')

# 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', output_format = html_document())
#out <- isolate(HTML(knit2html(text = input$rmd, fragment.only = TRUE, quiet = TRUE)))
file.rename(out, file)

}

I was thinking of changing the out variable to connect with the actual input$rmd editor but when I switched the commented out I get Error in file.rename(out, file) : expanded 'from' name too long. I've searching for a solution and none presently :cry:

gdancik commented 9 years ago

What is the value of out when you run the code? The render command should return the name of the HTML file, so I don't see why that would not work. That line after that (isolate(HTML(...)) returns HTML code, so with that uncommented I would expect the error.

In any case, the error is just in the renaming of the file. If you can't get around that, you could hardcode the file name to at least verify that the HTML file would be displayed correctly.

jasdumas commented 9 years ago

This is essentially what I see once I load the app and press the download button on the report page:

A blank HTML page is generated and saved to my desktop screenshot1

And this is what is displayed in console

Output created: report.html
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc report.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output report.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /var/folders/nv/c92g05zj4tnbkwp_x6y9ly6w0000gn/T//Rtmp8Sa4NE/rmarkdown-str1f9361be5a5.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/highlight 
jasdumas commented 9 years ago

So also its correctly creating a the report.html file but it just happens to be blank, which tells me that its not connected to that knitr output htmlOutput("knitDoc") or even the aceEditor, input$rmd I also think based on these examples that could be true that I need to include a statement within the downloadHandler of input$knitDoc for it to gather the desired plots/code:

http://shiny.rstudio.com/gallery/file-download.html https://github.com/rstudio/shiny-examples/tree/master/016-knitr-pdf

jasdumas commented 9 years ago

So now I changed this line out <- render('report.Rmd', output_format = html_document()) to out <- render(input$rmd, output_format = html_document()) and I got this output once I pressed the download button: inputrmd

So yeah that output file needs to be connected to the content! I'm still working on this for today