USGS - science for a changing world

Additional Topics in R

Spatial Analyses

Date Handling

Dates can be in a few different formats: character, numeric, POSIXlt, and POSIXct * Blog post about character and numeric formats: * Article about the Date class and POSIX classes (also has lots of useful examples): * Useful R package: lubridate, * Article describing date classes, the R packages chron and lubridate, and small intro to plotting with dates:


Trend Decomposition

Handling/Exporting Output

  • For tabular data, format it as a data frame. Then use the write.csv or write.table functions to export it
  • For exporting plots, there is a button in the plots tab in RStudio called “Export”. For in-line exporting of plots, you can save it in many formats using these functions: jpeg(), png(), pdf(), svg(), postscript()



Creating dynamic PDFs, word documents, or HTMLs. A place to have code and text all in one document. * Basic introduction to what R Markdown really is and how to apply it: * USGS uses R Markdown (NWIS Reporting Application - release date sometime in 2016)!! * Cheatsheet for R Markdown:


Lindsay R. Carr