How I stopped worrying about figure placement and learned to love Sweave - David Lovell

981 views

Published on

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!!!

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
981
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

How I stopped worrying about figure placement and learned to love Sweave - David Lovell

  1. 1. …and learned to love Sweave How I stopped worrying about figure placement David Lovell Bioinformatics FOAM | Melbourne | 14 February 2014 CSIRO COMPUTATIONAL INFORMATICS
  2. 2. It's doing the working and the thinking that wears a fellow out
  3. 3. I have an idea I want to explore it I explore my idea by writing a computer program I write R code I 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 authors I 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
  4. 4. 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 Journal Article .tex Journal Article .pdf
  5. 5. Let’s walk through the key steps
  6. 6. Let’s start a new project in RStudio
  7. 7. Let’s start a new project in RStudio
  8. 8. Let’s start a new project in RStudio
  9. 9. Let’s start a new project in RStudio
  10. 10. Let’s start a new project in RStudio
  11. 11. Let’s start a new project in RStudio
  12. 12. Let’s start a new project in RStudio
  13. 13. Be sure to set the project options…
  14. 14. … so as to use knitr to weave .Rnw files
  15. 15. You could also set knitr in the global options
  16. 16. You could also set knitr in the global options
  17. 17. Uncheck this option to keep .aux files
  18. 18. Now open a new Sweave (.Rnw) file…
  19. 19. Now open a new Sweave (.Rnw) file…
  20. 20. …for Supplementar y Information
  21. 21. This gives you a skeleton LaTeX file…
  22. 22. …add content …compile to PDF…
  23. 23. …here’s the compilation report…
  24. 24. …and here’s the resulting PDF
  25. 25. Now add code to execute on compilation
  26. 26. See the result?
  27. 27. Now add a “chunk” of code…
  28. 28. …here’s the pretty-printed result
  29. 29. Here’s a “chunk” that runs silently
  30. 30. …here’s the silent result
  31. 31. Now here’s a plot that prints immediately
  32. 32. See the result? Code first, plot after
  33. 33. Here’s a plot in a “floating” figure
  34. 34. The figure floats to the top of the page
  35. 35. Look at the files created on compilation
  36. 36. The .aux file holds labels for cross- reference
  37. 37. Compilation also creates figures…
  38. 38. …figures named after the chunks
  39. 39. Now let’s write that Nature paper…
  40. 40. …let’s call it JournalArticle
  41. 41. Now we play by Nature’s format rules
  42. 42. …still, we can cross- reference Suppl. Info.
  43. 43. …here’s a cross- reference
  44. 44. …and figures made in the Suppl. Info
  45. 45. 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 Journal Article .tex Journal Article .pdf
  46. 46. More thinking… less working… Workflow: write these How I learned to love Sweave| David Lovell | Page 47 Supplementary Information .Rnw Journal Article .tex
  47. 47. More thinking… less working… Workflow: submit these How I learned to love Sweave| David Lovell | Page 48 Supplementary Information .Rnw Supplementary Information .pdf Journal Article .tex Journal Article .pdf
  48. 48. It's doing the working and the thinking that wears a fellow out
  49. 49. Thank you CSIRO Transformational Biology David Lovell Bioinformatics and Analytics Leader t +61 2 6216 7042 e David.Lovell@csiro.au w www.csiro.au/people/David.Lovell CSIRO MATHEMATICS, INFORMATICS AND STATISTICS

×