how i stopped worrying about figure placement and learned to love sweave - david lovell

Post on 10-May-2015

535 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

As the artilleryman said in War of The Worlds: "It's doing the working and the thinking that wears a fellow out." And so it goes with doing the work of writing a journal paper after all that thinking (and R-coding) these past months. All those bits of code, lovingly crafted to work perfectly... but not in the hands of just anyone, no! Just me...and even then, things can go awry. And now those fancy journals come a-prancing, with their talk of formats and conventions. Well, I tell you, I won't be starting all over again. I'VE GOT A PLAN!!!

TRANSCRIPT

…and learned to love SweaveHow I stopped worrying about figure placement

David LovellBioinformatics FOAM | Melbourne | 14 February 2014

CSIRO COMPUTATIONAL INFORMATICS

It's doingthe working

and the thinkingthat wears

a fellow out

I have an ideaI want to explore it I explore my idea by writing a computer program

I write R codeI want to ensure my exploration is reproducible and comprehensible– I explore this idea using literate programming

I use Sweave to write both R code and commentary

I want to communicate my explorations I communicate my explorations by writing a journal article

I write the article according to the journal’s instructions for authorsI want to ensure others can reproduce and comprehend my explorations– I include the literate program as Supplementary Information– I use the Supplementary Information figures in the journal article

More thinking… less working…How to use Sweave to streamline data analysis and publication

How I learned to love Sweave| David Lovell | Page 3

More thinking… less working…Workflow

How I learned to love Sweave| David Lovell | Page 4

Idea

Supplementary Information

.Rnw

Figure 1.pdf

Supplementary Information

.aux

Supplementary Information

.pdf

JournalArticle

.tex

JournalArticle

.pdf

Let’s walk through the key steps

Let’s start a new project in RStudio

Let’s start a new project in RStudio

Let’s start a new project in RStudio

Let’s start a new project in RStudio

Let’s start a new project in RStudio

Let’s start a new project in RStudio

Let’s start a new project in RStudio

Be sure to set the project

options…

… so as to use knitr to weave .Rnw

files

You could also set

knitr in the global options

You could also set

knitr in the global options

Uncheck this option

to keep .aux files

Now open a new Sweave (.Rnw) file…

Now open a new Sweave (.Rnw) file…

…for Supplement

ary Information

This gives you a

skeleton LaTeX file…

…add content …compile to

PDF…

…here’s the compilation

report…

…and here’s the resulting

PDF

Now add code to

execute on compilation

See the result?

Now add a “chunk” of

code…

…here’s the pretty-printed result

Here’s a “chunk” that runs silently

…here’s the silent result

Now here’s a plot that

prints immediately

See the result? Code

first, plot after

Here’s a plot in a

“floating” figure

The figure floats to the top of the

page

Look at the files created

on compilation

The .aux file holds labels

for cross-reference

Compilation also creates

figures…

…figures named after the chunks

Now let’s write that Nature paper…

…let’s call it JournalArticl

e

Now we play by Nature’s

format rules

…still, we can cross-reference

Suppl. Info.

…here’s a cross-

reference

…and figures

made in the Suppl. Info

More thinking… less working…Workflow

How I learned to love Sweave| David Lovell | Page 46

Idea

Supplementary Information

.Rnw

Figure 1.pdf

Supplementary Information

.aux

Supplementary Information

.pdf

JournalArticle

.tex

JournalArticle

.pdf

More thinking… less working…Workflow: write these

How I learned to love Sweave| David Lovell | Page 47

Supplementary Information

.Rnw

JournalArticle

.tex

More thinking… less working…Workflow: submit these

How I learned to love Sweave| David Lovell | Page 48

Supplementary Information

.Rnw

Supplementary Information

.pdf

JournalArticle

.tex

JournalArticle

.pdf

It's doingthe working

and the thinkingthat wears

a fellow out

Thank youCSIRO Transformational BiologyDavid LovellBioinformatics and Analytics Leader t +61 2 6216 7042e David.Lovell@csiro.auw www.csiro.au/people/David.Lovell

CSIRO MATHEMATICS, INFORMATICS AND STATISTICS

top related