5

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):

2
  • Does the noweb style work? Commented Jul 5, 2016 at 1:32
  • 1
    It does yes. The example .mdw here runs fine with pweave -f pandoc FIR_design.mdw. I've made an edit to the below solution which solves the problem. Given an .Rmd file, use pweave -i markdown <source>.Rmd. Commented Jul 5, 2016 at 16:19

1 Answer 1

6
+50

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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.