pipelines Dr. Jennifer (Jenny) Bryan Department of Statistics and - - PowerPoint PPT Presentation

pipelines
SMART_READER_LITE
LIVE PREVIEW

pipelines Dr. Jennifer (Jenny) Bryan Department of Statistics and - - PowerPoint PPT Presentation

pipelines Dr. Jennifer (Jenny) Bryan Department of Statistics and Michael Smith Laboratories University of British Columbia saving figures to file do not save figures mouse-y style not self-documenting not reproducible


slide-1
SLIDE 1

pipelines

  • Dr. Jennifer (Jenny) Bryan

Department of Statistics and Michael Smith Laboratories University of British Columbia

slide-2
SLIDE 2

saving figures to file

slide-3
SLIDE 3

do not save figures mouse-y style not self-documenting not reproducible

http://cache.desktopnexus.com/thumbnails/180681-bigthumbnail.jpg

slide-4
SLIDE 4

pdf("awesome_figure.pdf") plot(1:10) dev.off()

postscript(), svg(), png(), tiff(), ....

most correct method:

slide-5
SLIDE 5

plot(1:10) dev.print(pdf,"awesome_figure.pdf")

fine for everyday use:

postscript(), svg(), png(), tiff(), ....

slide-6
SLIDE 6
  • If the plot is on your screen

ggsave("˜/path/to/figure/filename.png")

  • If your plot is assigned to an object

ggsave(plot1, file = "˜/path/to/figure/filename.png")

  • Specify a size

ggsave(file = "/path/to/figure/filename.png", width = 6, height =4)

  • or any format (pdf, png, eps, svg, jpg)

ggsave(file = "/path/to/figure/filename.eps") ggsave(file = "/path/to/figure/filename.jpg") ggsave(file = "/path/to/figure/filename.pdf")

Data Visualization with R & ggplot2 Karthik Ram

slide-7
SLIDE 7

typing in the R Console

slide-8
SLIDE 8

save commands in .r script, step through line by line w/ RStudio’s help

slide-9
SLIDE 9

source entire file with RStudio’s button

slide-10
SLIDE 10

source entire file from R command line

> source('darwin.r')

slide-11
SLIDE 11

source entire file from another R script

source(‘big_bang.r’) source(‘darwin.r’) source(‘zombie_apocalypse.r’)

slide-12
SLIDE 12

source entire file from shell

$ Rscript darwin.r > darwin.rout

  • r

$ Rscript -e "knitr::stitch_rmd('darwin.r')"

slide-13
SLIDE 13

execute file from a Makefile

darwin.html: darwin.r input-data.txt Rscript -e "knitr::stitch_rmd('darwin.r')"; rm -r darwin.md figure/*