Last active
December 15, 2015 09:29
-
-
Save daroczig/5238455 to your computer and use it in GitHub Desktop.
"pander"-only version of http://www.r-statistics.com/2013/03/write-ms-word-document-using-r-with-as-little-overhead-as-possible/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## load "pander" package | |
## http://rapporter.github.com/pander/ | |
library(pander) | |
## "brew" the below file to Pandoc's markdown | |
Pandoc.brew('example.brew') | |
## 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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
fit | |
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Doc header 1 | |
Some text explaining the analysis we are doing | |
---------------------------------- | |
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: | |
![](/tmp/RtmpD3QXAs/plots/4304da6127c.png) | |
And a model at last: | |
-------------------------------------------------------------- | |
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 |
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 'http://cran.cnr.Berkeley.edu/bin/macosx/leopard/contrib/2.15/ggplot2_0.9.3.1.tgz'
Content type 'application/x-gzip' length 2659920 bytes (2.5 Mb)
opened URL
==================================================
downloaded 2.5 Mb
The downloaded binary packages are in
/var/folders/Yq/YqZGRlFzE9yM-RL+qDXd0U+++TI/-Tmp-//RtmpTWO4zs/downloaded_packages`
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.
eipi10
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
Thanks @eipi10 for the bug report, that's definitely a bug in
pander
it seems. There is a command inPandoc.brew
[L134] where I try to remove absolute path from the generated image tags and your pretty strangebasedir
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!