Using an R Markdown style document (.Rmd) as input for Pweave

803 Views Asked by At

I'm trying to run a basic R Markdown document (that calls python in code chunks) through Pweave. In the Pweave documentation it states that you can declare code chunks using the style ```{python}. However when I try to compile using, for example, pweave -f pandoc FIR_design.mdw the chunks are not run and instead placed in verbatim.

All the examples in the documentation use the noweb syntax e.g.

<<fig = True, width = '12 cm', echo = False>>=
from pylab import *
plot(arange(10))
show()
@

The markdown equivalent would be:

```{python, fig = True, width = '12 cm', echo = False}
from pylab import *
plot(arange(10))
show()
```

When I try to run the examples using the markdown syntax it simply adds them in verbatim and doesn't run the chunk. Is this expected? If so, how should I be converting my .Rmd documents to make them runable in Pweave. Must I convert them to noweb style?

Here is the documentation example document FIR_design.mdw rewritten in .Rmd format (for examples):

1

There are 1 best solutions below

0
On BEST ANSWER

Instead of pweave -f pandoc <source> try using pweave -i markdown <source>.

If you do not provide the input format, it is deduced from file extension. As you can see in linked source, your input file needs to have the .md extension for it to be auto-detected as "Pandoc markdown" formatted.

The default output format seems to be the same as input, or as provided with --format (-f).