Skip to content

LaTeX consistent publication graphics from R and Comparison of GLE and R

6 messages · clangkamp, Frank E Harrell Jr, Marc Schwartz +1 more

#
Hi Everyone

I am at the moment preparing my thesis and am looking at producing a few
Organigrams / Flow charts (unrelated to the calculations in R) as well as a
range of charts (barcharts, histograms, ...) based on calculations in R. 

For the Organigrams I am looking at an Opensource package called GLE at
sourceforge, which produces the text part in Latex figures which is very
neat and also in the same style of the thesis, which I wrote in LaTeX. It
also offers a range of graphical features, and I am quite tempted.

It also produces barcharts and histograms with the options of legends etc. I
have done most of my graphs so far with R, but with Organigrams and flow
charts I am at a loss (A pointer here would also be very welcome). For some
charts I have used MS Visio, but it would be convenient to use just one
program for graphing throughout the thesis (i.e. same colour coding etc.).

Does anybody have any experience with GLE, ideally working with it with CSV
tables generated within R ? Or does there exist another way to generate
'visually LaTeX consistent' graphics within R ?

Any takers ?



-----
Christian Langkamp
christian.langkamp-at-gmxpro.de

--
View this message in context: http://r.789695.n4.nabble.com/LaTeX-consistent-publication-graphics-from-R-and-Comparison-of-GLE-and-R-tp4645218.html
Sent from the R help mailing list archive at Nabble.com.
#
On Oct 5, 2012, at 3:32 PM, clangkamp <christian.langkamp at gmxpro.de> wrote:

            
If you are comfortable in LaTeX, I would suggest that you look at PSTricks:

  http://tug.org/PSTricks/main.cgi

I use that for creating subject disposition flow charts for clinical trials with Sweave. I can then use \Sexpr{}'s to fill in various annotations in the boxes, etc. so that all content is programmatically created in a reproducible fashion.

There are some examples of flow charts and tree diagrams here:

  http://tug.org/PSTricks/main.cgi?file=pst-node/psmatrix/psmatrix#flowchart

and there are various other online resources for using PSTricks.

Keep in mind that since this is PostScript based, you need to use a latex + dvips + ps2pdf sequence, rather than just pdflatex.

Regards,

Marc Schwartz
#
Hi Marc,

It would be interesting to compare with tikz for ease of use.

As an aside I've been wishing that someone would write an R function for
creating clinical trial disposition charts using tikz or pstricks ...

Best,
Frank

Marc Schwartz-3 wrote

            
-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/LaTeX-consistent-publication-graphics-from-R-and-Comparison-of-GLE-and-R-tp4645218p4645269.html
Sent from the R help mailing list archive at Nabble.com.
#
Hi Frank,

I have not used tikz, so am not sure.

I have been hand coding the TeX markup in the .Rnw files to date, since each study has been somewhat different in terms of various characteristics and the sponsors, in some cases, have requested some customizations to the flow charts. That has typically been done with psmatrix constructs (http://tug.org/PSTricks/main.cgi?file=pst-node/psmatrix/psmatrix).

I have also used PSTricks, with pst-tree constructs (http://tug.org/PSTricks/main.cgi?file=pst-tree/pst-tree), to create branching trees for stratified randomization flow charts. So you have a top level with all enrolled subjects, then branches from there showing each stratification level, each box showing the sample size (using \Sexpr{}s) within each strata level. Similar concept to the matrix-like orgchart style used for disposition charts, but just a different implementation, which allows for an imbalance in the tree structure (eg. differing strata in each arm based upon various criteria, etc.).

I suppose that if one were to think about it conceptually, R's list structures would be a suitable substrate for creating an object that could be passed to a print method of sorts and generate the TeX markup during Sweave (or knitr) processing. I just have not spent the time to consider how that would be done generically enough and still allow for some of the customizations that might be encountered.

Food for thought.

Best regards,

Marc
On Oct 6, 2012, at 8:14 AM, Frank Harrell <f.harrell at vanderbilt.edu> wrote:

            
#
You can do everything in R and leave the dirty job to it the
tikzDevice package. For example, we can draw these charts with the
diagram package. To make things a little bit easier, we can put the
code in an Rnw document and compile with knitr. Attached is an example
of what we can achieve with:

\documentclass{article}
\begin{document}
<<flowchart, dev='tikz', cache=TRUE>>=
library(diagram)
demo('flowchart')
@
\end{document}

Note tikzDevices is not back to CRAN yet:
http://r.789695.n4.nabble.com/tikzDevice-not-available-td4640395.html

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
On Sat, Oct 6, 2012 at 8:14 AM, Frank Harrell <f.harrell at vanderbilt.edu> wrote:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 051-flowchart.pdf
Type: application/pdf
Size: 613045 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121006/6aa872e1/attachment.pdf>
#
I had a brief look at PSTricks, and really quite like it.
There is however one catch, like Sweave etc. it is assumed to be processed
along with the LaTeX. I find these things rather annoying, as it is just a
major and unnecessary error source. I think it is much better to produce
single objects (e.g. PNGs) and then embed them, like R does, without needing
to actually embed the R into the main text.

But many thanks for the pointer - I think it is probably the best bet to
continue formatting data from R as well as being able to produce organigrams
etc.





-----
Christian Langkamp
christian.langkamp-at-gmxpro.de

--
View this message in context: http://r.789695.n4.nabble.com/LaTeX-consistent-publication-graphics-from-R-and-Comparison-of-GLE-and-R-tp4645218p4645293.html
Sent from the R help mailing list archive at Nabble.com.