How do I include ggplots using pander's live report generation - windows

I am using pander to create docx reports via Windows7, following the examples at http://rapporter.github.io/pander/#live-report-generation.
myReport <- Pandoc$new(author="Jerubaal",title="Plot Anything", format="docx")
I've tried the example
myReport$add(plot(1:10))
and that doesn't work on Windows, but does on Linux.
Previously I got plots appearing using brew files and <%=plot(1:10)=>, but I am trying out the Live Report Generation because that method seems most suited to me.
I've also tried saving a plot to file first and then creating an image link, which again work in Linux, but not in Windows:
myReport$add("![](plots/myplot.png)")
I want to include ggplot2 plots - the code works on its own in R but doesn't appear in the docx (although I do get a blank line).
R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
pandoc.exe 1.12.2.1
What am I missing? Thanks.
Edit: I'm back home and this works on Ubuntu:
library(pander)
library(ggplot2)
setwd("/home/jerubaal/R/Projects/reports")
attach(movies)
m=movies[sample(nrow(movies), 1000),]
myReport=Pandoc$new(author="Jerubaal",title="Testing plots in reports",format="docx")
myReport$add.paragraph("There should be a plot after this")
p=ggplot(data=m, aes(x=rating,fill=mpaa)) + geom_density(alpha=0.25)
ggsave(filename=paste(getwd(),"plots/movies.png",sep="/"),plot=p,width=6,height=3)
myReport$add(paste("![](",paste(getwd(),"plots/movies.png",sep="/"),")",sep=""))
myReport$add.paragraph("There should be a plot before this")
myReport$export(tempfile())
Q: Would it cause a problem if the png took too long to create or save?

Related

Globbing a bunch of .pkl files into one, then converting to .fbx (on Windows)

I'm experimenting with the beautiful frankmocap, feeding a video and getting a quite accurate hands and body tracking. This tool also outputs a .pkl file (which I'm not familiar with) for each frame.
I'd like to convert these files into a usable 3D file but 1. I've discovered I can't use glob.h with ffmpeg on Windows and 2. I cant' get them converted in .fbx.
Along with frankmocap, I've tried VIBE but I still end up with the same problem.
Using miniconda3.
I hope someone can help me! Thank you for your time.
Someone has taken a useful script made for VIBE and adapted it to work with FrankMocap keypoints.
The script takes a folder of PKL frames generated by FrankMocap and then uses Blender to animate them into an FBX rig. It doesn't currently include the hands though, which is something I'm currently trying to solve in it myself (and how I found your question).
Link to the script: https://github.com/facebookresearch/frankmocap/files/5750266/fbx_output_FRANKMOCAP.zip

Can I use \input{file.tex} or similar to efficiently bring content (not a whole document) from a LaTeX file into a Jupyter notebook?

I am new to Jupyter notebooks and Python and have started using these to make materials for a workshop so that I can also produce a handout. I have useful content in various LaTeX files that I would like to include in a notebook.
I would like to know whether there is a command that will allow me to efficiently bring my already modularized content into a notebook. I will be happy to take suggestions on any approach to my problem in case the LaTeX route is the wrong way to proceed.
As a particular case, suppose an external file fig.tex has only a stand-alone tikzpicture (that I have successfully included in another LaTeX document). If I start a notebook code cell with
%%itikz and follow with \input{fig} I obtain error messages.
I can remedy the problem if I add a preamble with \documentclass{}, many necessary \usepackage{} and \usetikzlibrary{} commands (which I have already included at the top of the notebook), and wrap the content with begin/end document commands.
There is more manual handling here than I would like. Is there a more efficient way to include the tikzfigure content?
So it turns out with itikz you have an --implicit-pic option that fills in the preamble for you.
In principle, with this option, your cell would look like the following:
%%itikz --implicit-pic
% my awesome figure
\input{path/to/fig}
This creates a tex file populated like so:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[scale=1.0]
% my awesome figure
\input{path/to/fig}
\end{tikzpicture}
\end{document}
In addition when using an implicit-pic it is usefull to load tikz packages and set options . To quote from the Quickstart guide:
In an --implicit-pic, it's often useful to:
Set the \tikzpicture[scale=X] via --scale=<X> while iterating.
Set the \usepackage{X,Y,Z} via --tex-packages=<X,Y,Z>
Set the \usetizlibrary{X,Y,Z} via --tiz-libraries=<X,Y,Z>
For more info, see items 16-20 in the Quickstart notebook.

How to force rstudio/knitr/rmarkdown to use alternative pandoc binary (scholdoc)

scholdoc (see scholarlymarkdown.com) is a fork of pandoc that has !FINALLY! easy referencing of figures/code blocks etc. build in - a central missing piece in pandoc.
Is there any straight forward way to force usage of scholdoc instead of the shipped pandoc binary when using knitr/rmarkdown in rstudio?
When I set in .Rprofile
options(
rstudio.markdownToHTML = function(inputFile, outputFile) {
system(
paste(
"~/.cabal/bin/scholdoc",
shQuote(inputFile),
"-o", shQuote(outputFile)))
})
as indicated here, this seems to work, but, as it is missing all manner of command line options used by the internal pandoc, produces HTML out of the box and will lead me down a painful way of getting all the CLI options right.
After studying some rmarkdown code, I have also tried to set the environment variable RSTUDIO_PANDOC to contain the path of scholdoc - to no avail.
Can anyone point out an easy way to do this with up-to-date rstudio/scholdoc installations?
I asked this long ago an thought that for completeness sake, I'd point out, that bookdown has stepped into the arena to provide cross referencing of figures etc. within rmarkdown documents.
after issuing install.packages('bookdown'), RStudio may be coerced to use it by adding the following to the YAML header of a document:
output:
bookdown::pdf_document2:

Use Perl/GD to create and insert image directly into excel workbook?

I have had no luck figuring out how to insert an image (a gif in this case) created in perl with GD directly into an excel workbook, without first saving the image to a file. Is this possible using win32::OLE or one of the perl spreadsheet modules, or is there another trick I'm missing?
What I've tried:
searching google, stackoverflow, perlmonks
modules:
- spreadsheet::writeexcel
- excel::writer::xlsx
win32::OLE
- Pictures->Insert
- Shapes->AddPicture
All require a file as input; there was ONE (rejected) bug/patch to spreadsheet::writeexcel to allow inline images, but it didn't quite work and I'm disinclined to use non-baseline modules... any ideas?
Neither Spreadsheet::WriteExcel or Excel::Write::XLSX support adding images from anything other than a file.
I would suggest creating the images as temporary files, inserting them into a worksheet with Excel::Writer::XLSX (which has better image handling) and then removing the temporary files.

ghost script produce wrong pdf file with diffrent page size

I am using ghost script version "ghostscript-8.71" to produce pdf file in my application.
In window it produce the pdf file with size "8.26x11.69 (A4)" and Linux 8.5x11 (for India Locale) .
I want to make it consistent as per Window environment. So Linux also produce the same pdf file size i.e "8.26x11.69 (A4)" (for India locale only)
I found the file named "gs_init.ps"
under the directory "Resource\Init" which contain the settings.
I found while googling ie.
Find the line in "gs_init.ps"
% /DEFAULTPAPERSIZE (a4) def
Then to make A4 the default paper size, uncomment the line to change this to
/DEFAULTPAPERSIZE (a4) def
But it has no effect in Linux. How we can make Linux to produce the pdf file with same size as Window for locale(India).
Please help me in this regard.
Thanks & Regards
Vikas
Firstly, use an up to date version. The current version of Ghostscript is 9.10.
If you read the Ghostscript documentation you will find the same information you googled, in /ghostpdl/gs/doc/Use.htm#Paper_size, section 3.4, where it also says:
"Sometimes the initialization files are compiled into Ghostscript and cannot be changed."
Did you try simply setting -sPAPERSIZE=a4 ?

Resources