Skip to content

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
## load "pander" package
## "brew" the below file to Pandoc's markdown
## or convert to HTML at one go
## NOTE: `pandoc` is needed for the conversion
Pandoc.brew('example.brew', output = tempfile(), convert = 'html')
## or pdf/docx/odt
Pandoc.brew('example.brew', output = tempfile(), convert = 'pdf')
Pandoc.brew('example.brew', output = tempfile(), convert = 'docx')
Pandoc.brew('example.brew', output = tempfile(), convert = 'odt')
# Doc header 1
Some text explaining the analysis we are doing
summary(cars)# a summary table
Images should be in separate chunks not to be handles as inline image:
plot(cars) # a plot
And a model at last:
fit <- lm(dist~speed, data = cars)
# Doc header 1
Some text explaining the analysis we are doing
&nbsp; speed dist
------ ------------ --------------
**** Min. : 4.0 Min. : 2.00
**** 1st Qu.:12.0 1st Qu.: 26.00
**** Median :15.0 Median : 36.00
**** Mean :15.4 Mean : 42.98
**** 3rd Qu.:19.0 3rd Qu.: 56.00
**** Max. :25.0 Max. :120.00
Images should be in separate chunks not to be handles as inline image:
And a model at last:
&nbsp; Estimate Std. Error t value Pr(>|t|)
----------------- ---------- ------------ --------- ----------
**(Intercept)** -17.58 6.758 -2.601 0.01232
**speed** 3.932 0.4155 9.464 1.49e-12
Table: Fitting linear model: dist ~ speed


I'm new to the R/markdown/pandoc/knitr continuum and used your example to try to learn how to convert R Markdown files into MS-Word files. (Why would I want to do that, you ask? Well, my colleagues insist on using Word.) However, I ran into an error. The command Pandoc.brew('example.brew') ran just fine. But all of the next commands specifying output to html, docx, etc. produced the following error in the
R console:

Error in gsub(sprintf("]\\(%s/", basedir), "]\\(", res) :
invalid regular expression ']\(/var/folders/Yq/YqZGRlFzE9yM-RL+qDXd0U+++TI/-Tmp-//RtmpTWO4zs/',
reason 'Invalid use of repetition operators'

I get the same error even if the 'example.brew' file contains just a single sentence of plain text. I'm hoping you might know what's causing the problem. In case it might help, here's my R sessionInfo:

R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

attached base packages:
stats, graphics, grDevices, utils, datasets, methods and base
other attached packages:
knitr_1.1, pander_0.3.1, stringr_0.6.2, foreign_0.8-52, reshape2_1.2.2, car_2.0-16, nnet_7.3-5, MASS_7.3-23 and slidify_0.3.3
loaded via a namespace (and not attached):
digest_0.6.3, evaluate_0.4.3, formatR_0.7, markdown_0.5.4, plyr_1.8, tools_2.15.1, whisker_0.1 and yaml_2.1.7

Thanks for any suggestions you might have.



Thanks @eipi10 for the bug report, that's definitely a bug in pander it seems. There is a command in Pandoc.brew [L134] where I try to remove absolute path from the generated image tags and your pretty strange basedir produces a screwed up regular expression there. BTW is it normal to have a folder like /var/folders/Yq/YqZGRlFzE9yM-RL+qDXd0U+++TI/-Tmp-//RtmpTWO4zs/ on OSX?

Anyway, I will fix that on the GitHub version soon (in 24 hours), I promise. Thanks again!


Thanks for the quick reply @Daroczig. The weird directory is (AFAIK) a temporary (hidden) folder that OS-X creates in some download situations. I don't really know the details, but it does that in a wide range of situations, such as when installing an R package. For example, here's the output of a command I just ran in the R console:

> install.packages('ggplot2')
Installing package(s) into ‘/Users/eipi10/Library/R/2.15/library’
(as ‘lib’ is unspecified)
trying URL ''
Content type 'application/x-gzip' length 2659920 bytes (2.5 Mb)
opened URL
downloaded 2.5 Mb

The downloaded binary packages are in

I'm not sure why it works that way and I've never had a reason to try and find anything on those weird paths, but that's the way it seems to work.



Yeah, that's pretty normal after all it seems, I am just curious why this problem did not occurred recently.
Anyway, IMHO it's fixed in the GitHub version. Could you please verify, @eipi10?


Works fine now. Thanks very much for creating and maintaining pander!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.