Download presentation
Presentation is loading. Please wait.
Published byAndrew Strickland Modified over 9 years ago
1
KEEP THIS TEXT BOX this slide includes some ESRI fonts. when you save this presentation, use File > Save As > Tools (upper right) > Save Options > Embed TrueType Fonts (all characters) this will allow vector maps created with common ESRI symbols to show on computers that do not have ESRI software loaded a a a a a a a a a a a a a a a R, PostGIS, and Sweave: Reproducible Research Philip M. Hurvitz, PhD Urban Form Lab College of Built Environments University of Washington 1 of 12
2
Acknowledgments NIH 5R01HL091881-04 (PI B. Saelens) 2 of 12
3
Disclaimers I rarely make maps I use GIS for analytics (usually I want numbers and tables at the end of analyses) So this talk might not be for you... 3 of 12
4
Background Analysis is fun Writing is not fun Documentation is the most important, yet the most difficult part of research Typical workflows are not conducive to efficient documentation 4 of 12
5
The way most of us work Perform a bunch of analysis Generate summary tables as files Spreadsheet SQL database Programming (e.g., MATLAB, R, NumPy) Generate graphics as files ArcGIS Mapserver, QGIS, OpenJUMP Compile files in a word processed document “If it works,” don’t fix it. 5 of 12
6
But does it really work? What if you need to change something (who has ever needed to do that)? …Lather, rinse, repeat… 6 of 12
7
But does it really work? What if you need to revisit your analysis or results (say, during peer review)? If your results were copied into Excel & Word, how will you track down what you did? If you programmed your analyses, your workflow should be stored in scripts … But where are your scripts (“I swear they where here somewhere!”)? Or which version was used? 7 of 12
8
How to fix it? 1. Store your data in a format that can be accessed programmatically PostGIS (others?) 2. Program your analyses so they are replicable R with rgdal, RPostgreSQL 3. Use Sweave to run your R code and place results in a(and PDF) document 4. Use RStudio server to streamline the process Integrated development environment Persistent sessions Single-click from Rnw file to PDF file 8 of 12
9
How to do it Code your analysis in R Reformat your R code as an Sweave file (“.Rnw”) R code in “chunks” delimited with >= R code @ Manuscript in syntax Pass through Sweave and pdflatex R> Sweave(“file.Rnw”) $> pdflatex file.tex; pdflatex file.tex 9 of 12
10
Some details Use xtable library to format tabular data in format Generate graphics using native R or the lattice/grid graphical environment (Optional): Save tables and graphics as separate files (for publication) 10 of 12
11
A sample workflow Data: Simulated overlapping polygons (2 classes) Simulated point observations (2 classes) Analysis: Generate point density values for the 2 x 2 combination from intersected data 11 of 12
12
A demo Rnw code: http://gis.washington.edu/phurvitz/presentations/2012 /cugos_spring_fling/cugos.Rnw Resultant PDF http://gis.washington.edu/phurvitz/presentations/2012 /cugos_spring_fling/cugos.pdf 12 of 12
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.