300 likes | 394 Views
Introduction to. >. Biodiversity Informatics Training Workshop Boulder, CO. What is R. Open source interpreted programming language and development environment Initially release in 1993 Influenced by the S programming language Focus on statistics, data analysis & graphics
E N D
Introduction to > Biodiversity Informatics Training Workshop Boulder, CO
What is R • Open source interpreted programming language and development environment • Initially release in 1993 • Influenced by the S programming language • Focus on statistics, data analysis & graphics • Extensible via user contributed packages
Why R? • Reproducible, Repeatable Therefore a perfect tool for science • Method to track data and analytic flow Therefore a perfect tool for scientists
R & QGIS Integration {dismo}, {rgdal}, {rVertnet} • GetData • Prepare • Filter • Subset • Analyse • Model • Map Data • Derive surfaces • Subset • Create visuals Rasters: GeoTiff, .ASC, .BIL, Vectors: Shapefiles
Getting • www.r-project.org • Available for Windows, Macintosh, Linux & as Source Code • Current release (14 June 2013): R 3.0.1
Object-based functional language • What that means to users: Commands have three parts: arguments, body and its environment. A function is invoked by its name, followed by arguments, which can be named, positional or have defaults if omitted myvariable <- read.table(x, file = ”data.csv”, sep = ”,”)
Objects • Used to store values • Case sensitive • Named with alphanumeric characters • Cannot start with a number • Persistent until reassigned or removed from objects list. User rm(obj_name) to remove. • Values can be assigned to variables via <- or = • Use objects() orls() to view list of objects in the current environment.
Getting Help • ?fxn or help(fxn) > ?round
Extending R • Via user-created packages available from repositories • CRAN (Comprehensive R Archive Network) • Bioconductor
Installing and using Packages • Over 4,600 packages available. • Package: maps • Draw lines and polygons as specified by a map database. • Package: mapproj • Converts latitude and longitude into projected coordinates. Required by maps package, if we want to use projections other than default (rectangular). • Package: maptools • Set of tools for manipulating and reading geographic data, in particular ESRI shapefiles. Also installs package sp. • Package: sp • A package providing classes and methods for spatial data: points, lines, polygons and grids
Using Packages Rectangular projection Bonne equal-area projection
U.S. Census State Boundaries Results fromGeoreferencing
Filtering Data StateProvince==“Missouri” Use logical operators in filter expression: ==, >, <, <=, >=, <>
FishNet 2 Collaborative Georeferencing Project • http://geolocate.fishnet2.net/workflow.html
More Information http://cran.r-project.org/doc/manuals/R-intro.pdf
for Loops Syntax: for (name in expr1) expr2
Breaking out of Loops next can be used to discontinue the rest of a particular cycle and skip to the next iteration in the loop
while Loops Syntax: while (condition) expr
repeat Loops Syntax: repeat expr Expression is repeated until break is called