GithubHelp home page GithubHelp logo

rstudio / rmarkdown Goto Github PK

View Code? Open in Web Editor NEW
2.8K 146.0 966.0 122.53 MB

Dynamic Documents for R

Home Page: https://rmarkdown.rstudio.com

License: GNU General Public License v3.0

R 54.95% CSS 13.83% TeX 0.03% HTML 5.60% JavaScript 22.09% Lua 3.19% Shell 0.32% SCSS 0.01%
r r-package rmarkdown pandoc markdown literate-programming

rmarkdown's Introduction

rmarkdown

R-CMD-check CRAN release Codecov test coverage

The rmarkdown package helps you create dynamic analysis documents that combine code, rendered output (such as figures), and prose. You bring your data, code, and ideas, and R Markdown renders your content into a polished document that can be used to:

  • Do data science interactively within the RStudio IDE,

  • Reproduce your analyses,

  • Collaborate and share code with others, and

  • Communicate your results with others.

R Markdown documents can be rendered to many output formats including HTML documents, PDFs, Word files, slideshows, and more, allowing you to focus on the content while R Markdown takes care of your presentation.

Books

R Markdown: The Definitive Guide R Markdown Cookbook

See more about them in Get Started.

Installation

The easiest way to install the rmarkdown package is from within the RStudio IDE, but you don't need to explicitly install it or load it, as RStudio automatically does both when needed. A recent version of Pandoc (>= 1.12.3) is also required; RStudio also automatically includes this too so you do not need to download Pandoc if you plan to use rmarkdown from the RStudio IDE.

If you want to use the rmarkdown package outside of RStudio, you can install the package from CRAN as follows:

install.packages("rmarkdown")

If you want to use the development version of the rmarkdown package (either with or without RStudio), you can install the package from GitHub via the remotes package:

# install.packages("pak")
pak::pak('rstudio/rmarkdown')

If not using the RStudio IDE, you'll need to install a recent version of Pandoc (>= 1.12.3); see the Pandoc installation instructions for help.

Usage

The easiest way to make a new R Markdown document is from within RStudio. Go to File > New File > R Markdown. From the new file wizard, you may:

  • Provide a document title (optional but recommended),
  • Provide an author name (optional but recommended),
  • Select a default output format- HTML is the recommended format for authoring, and you can switch the output format anytime (required),
  • Click OK (required).

Once inside your new .Rmd file, you should see some boilerplate text that includes code chunks. Use the "Knit" button in the RStudio IDE to render the file and preview the output with a single click or use the keyboard shortcut Cmd/Ctrl + Shift + K.

You can also delete all the text below the YAML frontmatter and fill in your own .Rmd by:

  • Adding code chunks (keyboard shortcut: Ctrl + Alt + I; OS X: Cmd + Option + I),
  • Writing prose with Markdown formatting, and
  • Running each code chunk interactively by clicking the The run button icon within RStudio.

You can also click "Knit to HTML" again to render the full document with all code chunks. For more help getting started in R Markdown, please see the R Markdown website or use the "Get Started" links at the top of this page.

Getting help

There are two main places to get help:

  1. The Posit community is a friendly place to ask any questions about rmarkdown and the R Markdown family of packages.

  2. Stack Overflow is a great source of answers to common rmarkdown questions. It is also a great place to get help, once you have created a reproducible example that illustrates your problem.

Code of Conduct

Please note that the rmarkdown project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

rmarkdown's People

Contributors

adunning avatar aoles avatar apreshill avatar aronatkins avatar atusy avatar bearloga avatar byzheng avatar cboettig avatar cderv avatar cpsievert avatar gadenbuie avatar hadley avatar javierluraschi avatar jcheng5 avatar jennybc avatar jjallaire avatar jmcphers avatar kevinushey avatar kiwiroy avatar krlmlr avatar noamross avatar rich-iannone avatar rlesur avatar robjhyndman avatar schloerke avatar steveharoz avatar trestletech avatar wch avatar yihui avatar zeehio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rmarkdown's Issues

Graphics in word_document()

Very excited about the new rmarkdown package! I tried render("test.Rmd", word_document()) on an RMarkdown file containing the following simple R code chunk:

hist(rnorm(1000))

It successfully produces a Word document in Microsoft Word for Mac 2011. However, the defaults for this output format produce an unreadable graphic, unlike other formats like pdf_document() or html_document(). As a picture in the Word doc, the histogram is too large for the page and doesn't fit in the bounding box. Just an FYI.

Single call to render() to produce multiple output formats?

Is it possible to create two or more output formats (i.e., PDF and HTML) with a single call to the render function? I tried
render("Untitled.Rmd", output_format = c("pdf_document","html_document") )
to no avail. I also tried specifying multiple formats in YAML metadata both in the test file and as a separate output.yaml file; however, in the help file, I found that only the first defined formats used if no output_format is specified. Thanks for the help!

rmarkdown install

Hello,

A little question.

We have an internal server with no internet access (centos distrib). How should i proceed to installation of rmarkdown to generate reports?

The manual mentions devtools, i would suppose it requires access to github.

Cedric

run(dir="...") Fails if Working Dir has an "index.Rmd" in it

@jmcphers ,

(This is on the feature/shiny-dependencies branch).

I'm continuing to encounter some weirdness around the dir/file args in run(). I'm realizing that the PR I sent yesterday was indeed a partial fix for one of the issues, but didn't fix them all. I looked over the code as you have it now and didn't see an obvious fix so I thought I'd run it by you.

Part of the issue I believe is here: https://github.com/rstudio/rmarkdown/blob/feature/shiny-dependencies/R/shiny.R#L69 . There, we're checking for a file named index.Rmd (by default) not in the location specified by dir, but in the current directory -- creating errors like:

Error in run(dir = "/home/shiny/ShinyApps/rmd") : 
  The file '/home/shiny/index.Rmd' does not exist in the directory '/home/shiny/ShinyApps/rmd'

(where /home/shiny is the working directory.) Often when the working directory does not have an index.html file, I'll get an error or warning about the file not existing.

My PR doesn't do much better in this environment, unfortunately:

Error in run(dir = "/home/shiny/ShinyApps/rmd") : 
  The file '/home/shiny/ShinyApps/rmd//home/shiny/index.Rmd' does not exist

The path is absolute to help with detecting whether or not the file exists, but doesn't join cleanly onto the dir argument.

multiple yaml output specifications doesn't seem to work

This might be a local config problem but the documented format for multiple output types does not appear to work on my machine. I get the first format but not the second. If I use either format by itself it works fine. This happens even with the simplest .Rmd documents


---
title: "Sample Document"
output:
  html_document:
    toc: true
    theme: united
  pdf_document:
    toc: true
    highlight: zenburn

---

The above will generate the html file but not the pdf. If I remove the html spec then I get the pdf doc.

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] sqldf_0.4-7           RSQLite.extfuns_0.0.1 RSQLite_0.11.4       
 [4] DBI_0.2-7             gsubfn_0.6-5          proto_0.3-10         
 [7] wavelets_0.3-0        vegan_2.0-10          lattice_0.20-24      
[10] permute_0.8-3         Rsamtools_1.13.52     Biostrings_2.29.19   
[13] xtable_1.7-1          rtracklayer_1.21.14   GenomicRanges_1.14.4 
[16] XVector_0.1.4         IRanges_1.20.6        BiocGenerics_0.7.8   

loaded via a namespace (and not attached):
 [1] bitops_1.0-6     BSgenome_1.29.1  chron_2.3-44     evaluate_0.5.1  
 [5] formatR_0.10     grid_3.0.2       knitr_1.5        RCurl_1.95-4.1  
 [9] rmarkdown_0.1.23 stats4_3.0.2     stringr_0.6.2    tcltk_3.0.2     
[13] tools_3.0.2      XML_3.98-1.1     yaml_2.1.10      zlibbioc_1.7.0  

Minimal md_document experience-2

Clarification and continuation of #26

Part 1

What I did::

  1. Open an RStudio session.
  2. File -> New R-Markdown -> leave unnamed
  3. Alter output to md_document
  4. knit via ctrl-shift-k

What happened::

Instead, a markdown .md document is presented in a tab ("OK, I like that.") and when preview html is clicked I am presented with an error...

pandoc: Could not find data file Preview-24af7a34924e_files/figure-markdown_strict/unnamed-chunk-2.png
Error: pandoc document conversion failed
Execution halted

What I expect::

At this point I expect the markdown document .md to be created and available in my path and the preview panel to open and display the pandoc rendered output in the html preview pane.


  • Part 2 *

Without closing the Part 1 session, repeat the steps of Part 1 in a new RStudio Session.

What happens::

The markdown document displays in the first session.

What I expect::

Display the markdown document in the active session.

Note:
If the first session is now closed, and the document in the second session is knit the preview opens a new RStudio session to display the results.


What I really expect is that changing the output to md_document (without giving a flavor) will give the same .md document as when render("./file_path", clean=FALSE) is used. Right now I'm investigating why this doesn't happen and these issues are just things that I'm running into while investigating.

Single quotes replaced with double quotes inside script blocks

I'm trying to inline some scripts into a markdown document. I'm running into a problem where single quotes are replaced with double quotes. For example, take this source document:

Title
========================================================

The code inside the script block doesn't appear correctly when this is rendered with the rmarkdown package.

<script>
var foo = "<a href='/a'>a</a><input type='checkbox'/>"
</script>

Text Text Text

After running rmarkdown::render on it, the resulting html file has this:

<script>
var foo = "<a href="/a">a</a><input type="checkbox"></input>"
</script>

Would be nice to have ability to go to original document from the embedded.

Using RStudio Version 0.98.797

sessionInfo()

R version 3.1.0 (2014-04-10)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
 [1] devtools_1.5     digest_0.6.4     evaluate_0.5.3   formatR_0.10    
 [5] httr_0.3         knitr_1.5.31     memoise_0.1      parallel_3.1.0  
 [9] RCurl_1.95-4.1   rmarkdown_0.1.84 stringr_0.6.2    tools_3.1.0     
[13] whisker_0.3-2    yaml_2.1.11     

  • Create a Shiny R Markdown document from template (as described in http://rmarkdown.rstudio.com/authoring_shiny.html)
  • Add a link to another Rmd document within this document.
  • Run Document
  • Click on the link to the embedded document
  • Viewer goes to the embedded document, but there is no way to go back to original docment. Would be nice to have that ability.

render() (really pandoc) can hang under certain circumstances

This is not a bug in rmarkdown. I report it here because it manifests itself by hanging rmarkdown::render() so there should be a record of what is really going on.

render() tries to establish the version of pandoc available. During this process 'pandoc --version' can hang forever (while using up all available memory) which causes render() to also hang forever.

I noticed this when trying to run render() in an ESS session running R on a remote server using tramp mode. The environment on the remote ubuntu system apparently sets LC_ALL=C as part of it's localization. As far as I can tell, on a ubuntu machine if the LC_ALL environment variable is set (to anything at all), the statically linked version of pandoc will hang.

This situation sounds exactly like โ€‹(this bug)[https://ghc.haskell.org/trac/ghc/ticket/7344] reported 17 months ago.

Symptoms are 'pandoc --version' hangs and consumes memory until the process eventually dies with an OOM error. This seems to only happen when LC_ALL is set in the environment, and only when running the statically linked pandoc.

$ uname -a
Linux server 3.5.0-43-generic #66~precise1-Ubuntu SMP Thu Oct 24 14:52:23 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

$ wget https://s3.amazonaws.com/rstudio-buildtools/pandoc-1.12.3.zip

$ unzip pandoc-1.12.3.zip

$ file pandoc-1.12.3/linux/debian/x86_64/pandoc
pandoc-1.12.3/linux/debian/x86_64/pandoc: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.15, BuildID[sha1]=0x9bc69f51b7c213cf58e9f8692f4b46f9f05fb723, not stripped

# buggy behavior
$ LC_ALL=C strace -e trace=open,close  pandoc-1.12.3/linux/debian/x86_64/pandoc --version
open("/usr/lib/gconv/gconv-modules.cache", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/gconv/gconv-modules", O_RDONLY) = -1 ENOENT (No such file or directory)
--- SIGVTALRM (Virtual timer expired) @ 0 (0) ---
--- SIGVTALRM (Virtual timer expired) @ 0 (0) ---
--- SIGVTALRM (Virtual timer expired) @ 0 (0) ---
--- SIGVTALRM (Virtual timer expired) @ 0 (0) ---
^C--- SIGINT (Interrupt) @ 0 (0) ---

# correct behavior
$ strace -e trace=open,close  pandoc-1.12.3/linux/debian/x86_64/pandoc --version
open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
close(3)                                = 0
pandoc 1.12.3
Compiled with texmath 0.6.6, highlighting-kate 0.5.6.
Syntax highlighting is supported for the following languages:
    actionscript, ada, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog,
    clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d,
    diff, djangotemplate, doxygen, doxygenlua, dtd, eiffel, email, erlang,
    fortran, fsharp, gnuassembler, go, haskell, haxe, html, ini, java, javadoc,

Note this problem does not occur if I run an older dynamically linked pandoc under the same circumstances.

$ LC_ALL=C /usr/bin/pandoc --version
pandoc 1.9.1.1
Compiled with citeproc-hs 0.3.4, texmath 0.6.0.3, highlighting-kate 0.5.0.5.
Syntax highlighting is supported for the following languages:
    Actionscript, Ada, Alert, Alert_indent, Apache, Asn1, Asp, Awk, Bash,
    Bibtex, Boo, C, Changelog, Clojure, Cmake, Coffeescript, Coldfusion,
    Commonlisp, Cpp, Cs, Css, D, Diff, Djangotemplate, Doxygen, Dtd, Eiffel, ...

Shiny outputs disappear from slide presentation after pages are added/removed

Using RStudio Version 0.98.792

sessionInfo()

R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] shiny_0.9.1.9003

loaded via a namespace (and not attached):
 [1] bitops_1.0-6     caTools_1.16     digest_0.6.4     evaluate_0.5.3  
 [5] formatR_0.10     httpuv_1.2.3     knitr_1.5.31     Rcpp_0.11.0     
 [9] RCurl_1.95-4.1   RJSONIO_1.0-3    rmarkdown_0.1.84 RSelenium_1.2.2 
[13] stringr_0.6.2    tools_3.0.1      XML_3.95-0.2     xtable_1.7-1    
[17] yaml_2.1.10     

  • Using the Shiny template for R Markdown document, changing the output to "ioslides_presentation", and adding page delimations (a simplifies example at the end), Run Document opens the presentation in a viewer and Shiy outputs (table, plot, ...) are all there.
  • Now remove a section and save; add the section back and save. Presentation might not be showing the Shiny outputs anymore.

Note: In the following example, the ``` are escaped for inclusion in the ticket; they should be adjusted.


---
title: "Shiny Document"
output: ioslides_presentation
runtime: shiny

---
## Title

This R Markdown document is made interactive using Shiny (for more information on Shiny see <http://shiny.rstudio.com>). Note that R Markdown documents using Shiny can currently only be run locally (support for running them within Shiny Server will be available soon).

## Table

You can embed Shiny inputs and outputs in your document. Outputs are automatically updated whenever inputs change. In this example we create a `numericInput` with the name "rows" and then refer to it's value via `input$rows` when generating output:

\```{r, echo=FALSE}
numericInput("rows", "How many cars?", 5)

renderTable({
  head(cars, input$rows)
})
\```

## Plot

In this example the output code was wrapped in a call to `renderTable`. There are many other render functions in Shiny that can be used for plots, printed R output, and more. This example uses `renderPlot` to create dynamic plot output:

\```{r, echo=FALSE}
sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30)

renderPlot({
  x <- faithful[, 2]  # Old Faithful Geyser data
  bins <- seq(min(x), max(x), length.out = input$bins + 1)

  # draw the histogram with the specified number of bins
  hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
\```

Images do not appear with runtime:shiny

My images do not appear when I run a Shiny document. For example, this document does not find the image mentioned


---
title: "Shiny Document"
output: html_document
runtime: shiny

---

This is a picture.

![logo](images/RStudioLogoTM.png)

If I take out runtime:shiny, the RStudio Run Document option turns into a Knit HTML option and the images begin to work. For example, this document does find the image mentioned


---
title: "Shiny Document"
output: html_document

---

This is a picture.

![logo](images/RStudioLogoTM.png)

This pattern occurs whether I put the image in a sub-directory or not.

Minimal md_document experience.

Something is borked with the default setup.

  1. File -> New Markdown Document
  2. Change output to md_document and then knit. (ctrl-shift-k)
  • knitr runs
  • preview opens
  • a Download File dialog opens ?
    (Closing, cancelling, or giving a file name doesn't seem to make a difference).
  • Preview is empty.
  • No .md file exists.
  1. Try again after saving the .Rmd.
  • Results are the same as above but the .md gets created.
  • Open the .md
  • Preview html
    pandoc error on the figure path.
  1. Add a fig.path to the plot chunk and knit again.
  • Same dance as above but after opening the .md a preview can be done.

Contrast this experience to the current stable release method of generating and previewing a markdown file.

Perhaps the wrong code path is being taken or some such? I didn't get a chance to debug or trace, but it is pretty obvious something is wrong when you get a 'Download File' dialog. ;)

Enhancement suggestion - make the PDF versions of the documentation

I do a lot of reading offline on smartphones / tablets and have figured out how to build the 'gh-pages' in PDF format.

  1. There's a dependency on the 'framed.sty' LaTeX style. On Fedora Linux, you need to install the 'texlive-framed' package. I don't know what it would be in other environments.

  2. Add the following lines to _output.yaml:

    pdf_document:   
    toc_depth: 2   
    highlight: default
    
  3. Add entries to the Makefile for the PDFs.

enable access to metadata within knit environment

It would be useful in the code in the Rmd document could easily access
the variables in the yaml metadata. Maybe bind to rmarkdown (or
metadata?) in the global environment when the code is knit?

Then you could do things like:


---
title: my title

---

```{r}
plot(1:10, main = metadata$title)
```

I can imagine this might be a useful way of parameterising reports so
you only need to change something in one place.

Link to external URLs does not work from RStudio Viewer

Using RStudio Version 0.98.797

sessionInfo()

R version 3.1.0 (2014-04-10)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
 [1] devtools_1.5     digest_0.6.4     evaluate_0.5.3   formatR_0.10    
 [5] httr_0.3         knitr_1.5.31     memoise_0.1      parallel_3.1.0  
 [9] RCurl_1.95-4.1   rmarkdown_0.1.84 stringr_0.6.2    tools_3.1.0     
[13] whisker_0.3-2    yaml_2.1.11     

Note: Links to other Rmd documents works fine.

This could be an RStudio issue, but opening here first.

Package startup messages disappear after a save causes re-knit

This isn't a huge problem, but it is a little surprising. For example, doing this in a document results in a lot of startup messages:

library(ggvis)

But once you make a change to the document and save, the document reloads, and the messages go away.

A more general way to state the issue is: code that modifies global state can have effects that carry over to new sessions, which can cause unexpected behavior.

render pdf fails

Hello,

I was able to use render to create an html document but failed on both windows and osx when trying to create a PDF. I have texlive installed and use it regularly to compile documents using pdflatex.

in R studio I selected new markdown document. Saved it to a local directory. Then ran the following code:

render('test1.Rmd',pdf_document())

On OSX I received an error about needing to install X11. RStudio crashed at that point.

On windows I was able to get an error message in the console.

processing file: test1.Rmd
  |.............                                                    |  20%
  ordinary text without R code

  |..........................                                       |  40%
label: unnamed-chunk-1
  |.......................................                          |  60%
  ordinary text without R code

  |....................................................             |  80%
label: unnamed-chunk-2 (with options) 
List of 2
 $ fig.width : num 7
 $ fig.height: num 6

  |.................................................................| 100%
  ordinary text without R code


output file: test1.knit.md

C:/Users/stephen/AppData/Local/Pandoc/pandoc test1.knit.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-markdown_in_html_blocks --output test1.pdf --filter C:/Users/stephen/AppData/Local/Pandoc/pandoc-citeproc --template C:/Users/stephen/R/win-library/3.0/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable geometry:margin=1in 
pandoc.exe: Error producing PDF from TeX source.
! LaTeX Error: File `article.cls' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: cls)

Enter file name: 
! Emergency stop.
<read *> 

l.2 \usepackage

Error: pandoc document conversion failed
In addition: Warning message:
running command 'C:/Users/stephen/AppData/Local/Pandoc/pandoc test1.knit.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-markdown_in_html_blocks --output test1.pdf --filter C:/Users/stephen/AppData/Local/Pandoc/pandoc-citeproc --template C:/Users/stephen/R/win-library/3.0/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable geometry:margin=1in' had status 43 

Generated default info in metadata?

If we can't change it then there shouldn't be any danger in passing it along, but by not passing it along knitr chunks, hooks and packages providing features can not exploit it to its full potential from within the environment...

"Run Document" command on the toolbar does not work after opening a link.

Using RStudio Version 0.98.792

sessionInfo()

R version 3.0.1 (2013-05-16)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] shiny_0.9.1.9003

loaded via a namespace (and not attached):
 [1] bitops_1.0-6     caTools_1.16     digest_0.6.4     evaluate_0.5.3  
 [5] formatR_0.10     httpuv_1.2.3     knitr_1.5.31     Rcpp_0.11.0     
 [9] RCurl_1.95-4.1   RJSONIO_1.0-3    rmarkdown_0.1.84 RSelenium_1.2.2 
[13] stringr_0.6.2    tools_3.0.1      XML_3.95-0.2     xtable_1.7-1    
[17] yaml_2.1.10     

  • Create a Shiny R Markdown document from template (as described in http://rmarkdown.rstudio.com/authoring_shiny.html)
  • Run Document from the toolbar.
  • This document has a link to http://shiny.rstudio.com. Try to open the link. This does not work. But you can open the link in a new window. This opens a blank viewer page, and then opens the link in a browser page.
  • Close the browser page, and the viewer pages.
  • Back in RStudio, try Run Document from toolbar menu; it does not launch the document.

Note: "rmarkdown::run()" command works fine.

Viewing Equations in Preview HTML after rendering

I have been experimenting with setting the Knit HTML button to use render and seem to have it working to my liking. It nicely URI-encodes images and CSS while calling out to a script for mathjax (something pandoc alone does not seem capable of doing, as far as I can tell).

When viewing the produced HTML file in Chrome, everything looks great, including equations. However, in the Preview HTML pane that opens after knitting (Ctrl+Shift+H) the equations are written as text. For some reason the mathjax equations are not rendering.

A barebones Rmd file follows:


---
title: "Portfolios"
author: "Jared P. Lander"
date: March 14, 2014
output:
  revealjs_presentation:
    mathjax: "default"
    center: true

---

# Portfolio Optimization

# Definitions

$n$ Assets  
$A_i$ Asset  

# Relative Investment
$$
    \sum_{i=1}^n w_i = 1
$$

And my settings are:

options(rstudio.markdownToHTML = 
            function(inputFile, outputFile) {
                rmarkdown::render(input=inputFile, output_format=revealjs_presentation(center=TRUE), output_file=outputFile, clean=TRUE)
            }
)

Is this an issue with the Preview window or something else?

pandoc problem on windows 7

I am running the preview version 0.98.703 of Rstudio on Windows 7 x64. I got the following message when tried to compile an Rmarkdown file:

...
output file: desc-normal-watch.knit.md

pandoc.exe: Failed to retrieve C:/Users/Howard/R/win-library/3.0/rmarkdown/rmd/h/jquery-1.10.2/jquery.min.js
InvalidUrlException "C:/Users/Howard/R/win-library/3.0/rmarkdown/rmd/h/jquery-1.10.2/jquery.min.js" "Invalid scheme"
Error: pandoc document conversion failed
In addition: Warning message:
running command 'C:/Tools/RStudio/bin/pandoc/pandoc desc-normal-watch.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output desc-normal-watch.html --filter C:/Tools/RStudio/bin/pandoc/pandoc-citeproc --section-divs --smart --self-contained --table-of-contents --toc-depth 3 --template C:\Users\Howard\R\win-library\3.0\rmarkdown\rmd\h\default.html --variable jquery:C:/Users/Howard/R/win-library/3.0/rmarkdown/rmd/h/jquery-1.10.2 --variable bootstrap:C:/Users/Howard/R/win-library/3.0/rmarkdown/rmd/h/bootstrap-3.0.3 --variable theme:C:\Users\Howard\R\win-library\3.0\rmarkdown\rmd\h\bootstrap-3.0.3\css\bootstrap.min.css --no-highlight --variable highlightjs=C:\Users\Howard\R\win-library\3.0\rmarkdown\rmd\h\highlight --mathjax --variable mathjax-url:https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' had status 61
Execution halted

I also tried different daily builds of RStudio using rmarkdown on Windows, the problem remains the same. Since the .md file is successfully generated, I think it might be a problem of rmarkdown.

Default fonts in preview of R markdown documents

To keep up on the latest and greatest versions of rmarkdown (which is fantastic, thanks for all the work on it) I have installed the prerelease snapshots of RStudio. Up until the version that I installed on Monday fixed-width fonts were used in the R code and R output chunks. Starting with the version installed on Monday and continuing with today's snapshot (0.98.751) the code and output chunks are in a san-serif but variable width font.

Should I change something in the preamble to my .Rmd document?

By the way, you may want to change the copyright dates in the "About RStudio" panel to 2009-2014

self contained

Hello,

Thought I could help test this.

Does self contained include mathjax embeded in the web document? So if after rendering a r markdown file with an equation in it, should I be able to open the generated html file in a web browser offline? I thought I would start here as it is a very often overlooked feature in other apps.

LaTeX Error: File `framed.sty' not found.

Knit PDF and got the error output:

/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc t.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output t.pdf --filter /Applications/RStudio.app/Contents/MacOS/pandoc/pandoc-citeproc --template /Users/13k/R/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable geometry:margin=1in 
output file: t.knit.md

pandoc: Error producing PDF from TeX source.
! LaTeX Error: File `framed.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name: 
! Emergency stop.
<read *> 

l.31 \definecolor

Error: pandoc document conversion failed
Execution halted

my env:

> system('kpsewhich framed.sty')
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
[1] rmarkdown_0.1.19 tools_3.0.2      yaml_2.1.10     
> Sys.getenv('PATH')
[1] "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin"

system('kpsewhich framed.sty') returns nothing
i found a framed.sty in knitr package located:/Users/13k/R/knitr/misc
my TeX is TeXLive-2013-Basic
snip20140330_44
so, how to fixed this issue: File 'framed.sty' not found.

unable to render document a second time with custom cache.path

The render function sets the fig.path function so that all figures end up in a predictable directory (e.g. for rendering "input.Rmd" to HTML it would be "input_files/figure_html"). This is for two reasons:

  1. So that for non self-contained HTML dependent files end up in a single directory that can be easily transported along with the base page.
  2. So that each distinct output format rendered has it's own figure directory (since they often have different default sizes).

For self_contained HTML the render function also removes the "input_files" directory after rendering (to leave a clean directory). Unfortunately if caching is enabled this results in the cached figures disappearing from underneath the cache! Therefore, render also sets the cache.path to e.g. "input_cache" and then preserves "input_files" if the cache was written to.

This is problematic in the case where the user sets a custom cache directory within their Rmd file. In this case render is unable to detect that a cache was used and goes ahead and deletes the "input_files/figure-html" directory (thus messing up the cache and making the next render fail).

What we really need is the ability for render to call knit and then after the fact detect whether any cached output was written (and in that case preserve input_files).

@yihui Is there a knir hook we could write that would reliably detect whether any cached output was created or referenced during a knit?

Access to .tex sourcefile when rendering to markdown pdf ?

I'm just discovering the preview release of rstudio and noticed that this new rmarkdown package seems to improve a lot of things in regard to original markdown format. Thanks a lot for this work !

When submitting a pdf rendered from rstudio to arXiv.org, the website detected a pdflatex output and ask for the source .tex file. From what i can understand, the call to pandoc from rstudio uses a lot of arguments and temporary files.
Is there an easy way to get access to the .tex file before it is processed by pdflatex ?

Thanks

"Knit HTML" button envir vs rmarkdown::render()

Hi guys!

Let me start with WOO-HOO! I'm almost in bliss with the direction your taking rmarkdown with pandoc. It's fantastic!

A couple of questions though:

  • I added a knitr_front_matter var to render() to capture knitr meta just after output_format_from_yaml_front_matter and before create_output_format then a second block to merge the knitr data after the first block that sets knitr data from output_format:
    # merge user options and hooks
    if (!is.null(knitr_front_matter)) {
      knitr::opts_knit$set(as.list(knitr_front_matter$opts_knit))
      knitr::opts_chunk$set(as.list(knitr_front_matter$opts_chunk))
      knitr::knit_hooks$set(
        lapply( as.list(knitr_front_matter$knit_hooks), match.fun) )
    }

With that I'm able to successfully set a simple hook from R global env using render() but when I test with the 'knit html' button I get:

Error in get(as.character(FUN), mode = "function", envir = envir) : 
  object 'myhook2' of mode 'function' was not found
Calls: <Anonymous> -> <Anonymous> -> lapply -> FUN -> get
Execution halted

Which makes me think it is a different environment. I had thought that the knit html button called render, but I haven't figured out how to debug via the knit html button to verify. Am I on the right track with the logic, and if so how would you suggest to proceed with capturing the envir?


  • Is there a flag within the processing environment to indicate a version 1 rmarkdown vs version 2? With the pandoc markdown being the new output and having so many more capabilities it'd be nice to be able to be backward compatible with hooks and such.

  • What do you think of adding a checkmark box to the Edit R Markdown Options to control the clean option? It might really help devs and customizers. ( I keep forgetting to run from the command prompt with clean=FALSE and do [ctrl]+[shift]+[k] instead; then get the popup saying the file has been deleted when I switch to the tab to verify output. )

Thanks again for the rock-star quality work!

Sincerely,
Thell

Trying to Add Shiny to a PDF Gives a Non-Helpful Error

I created a presentation to use ioslides, adding runtime: shiny works great. If I remove that and go to render a Beamer presentation, that works, as well. However, if I then add runtime shiny (as in this file), I get a new window that says:

Error: unused argument (self_contained = FALSE)

and the R Markdown console contains:

Loading required package: shiny

Listening on http://127.0.0.1:4552
Error in (function (toc = FALSE, slide_level = NULL, incremental = FALSE,  : 
  unused argument (self_contained = FALSE)
Error in (function (toc = FALSE, slide_level = NULL, incremental = FALSE,  : 
  unused argument (self_contained = FALSE)

Expected behavior: that I would either be forbidden from trying to run if I'm in PDF mode or given a more informative error about what's failing.

md_document default variant should match rmarkdown_format default.

Documentation leaves confusion as to what is produced.

Help for ?rmarkdown makes no mention of how to produce a markdown document.
Following the first See Also to render makes mention of R Markdown in its own section which says it supports all features of the base pandoc, yet makes no mention of how to produce it and provides a link to rmarkdown_format, which states

By default R Markdown is defined as all pandoc markdown extensions...

this is for the from argument of pandoc options. Still no mention of how to produce the markdown document.

Going to the RStudio ? help link and reading through the first page also makes no mention of producing a markdown document and is not listed in the output formats nor in the links under Learning More.

Finally under the dropdown Formats there is a markdown, and right at the top it states to use md_document. Woot! Yet, if you stop reading there (now that you have the answer of how to create one, and the belief you get pandoc functionality) you'd be sorely disappointed when you try a pandoc construct, as the next section clearly states that the default is markdown_strict.

Options set in a document function should not permanently set the global option state.

Simple reproducible example, the key change here is setting the upload.fun option, this setting should not persist across render calls.

simple_html_format <- function() {
  require(rmarkdown)
    output_format(knitr = knitr_options(opts_knit = list(upload.fun= knitr::image_uri),
                                        opts_chunk = list(dev = 'png')),
        pandoc = pandoc_options(to = "html"))
}
#works fine
render('../vignettes/cars.Rmd', pdf_document())
#also works fine, but sets an option which breaks pdf_document
render('../vignettes/cars.Rmd', simple_html_format())
#breaks
render('../vignettes/cars.Rmd', pdf_document())

You can get the last render to work if you opts_knit$restore() after the simple_html_format call

I think the proper fix for this is to save all the option states before running a render, then restoring them after.

Best place to contribute custom formats.

This is not a typical bug issue, but I wanted to get your input on the best place to contribute new custom formats.

I am planning on getting my knitrBootstrap package to work with the rmarkdown package through a custom output function.

It currently does very similar things to your current html implementation as they both use Bootstrap, but utilizes more bootstrap classes than the current html output, and has added features like code, output and figure toggling.

My question is would you prefer I keep my code in a separate package, or would you accept a pull request adding the knitrBootstrap functionality to the rmarkdown package directly?

Thanks for your work on this, it seems like a great step in making reproducible research easier to create and display to a wide variety of formats.

Inline HTML with indentations gets treated as code

I'm putting HTML inline in a Markdown document. When the source contains this:

<div>
    <div>bar</div>
</div>

It gets translated to this:

<div>
<pre><code>&lt;div&gt;bar&lt;/div&gt;</code></pre>
</div>

Oddly, if you add some text on the first line with the <div>, it changes which parts are treated as code.

<div>foo
    <div>bar
        <div>boo</div>
    </div>
</div>

becomes:

<div>
foo
<div>
bar
<div>
boo
</div>
<pre><code>&lt;/div&gt;</code></pre>
</div>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.