Presentation is loading. Please wait.

Presentation is loading. Please wait.

> Introduction to Nelson Rios, Tulane University

Similar presentations


Presentation on theme: "> Introduction to Nelson Rios, Tulane University"— Presentation transcript:

1 > Introduction to Nelson Rios, Tulane University
Biodiversity Informatics Training Workshop Boulder, CO

2 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

3 Getting R www.r-project.org
Available for Windows, Macintosh, Linux & as Source Code Current release (30 Mar 2012): R

4 RGui

5 Working directory Default location used to save and retrieve files.
Use getwd() to determine current working directory Use setwd(new_path) to change current working directory

6 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() or ls() to view list of objects in the current environment.

7 Logical Operators == Equal to > Greater than < Less than <=
Less than or equal to >= Greater than or equal to <> or != Not equal to

8 Example Code

9 Getting Help ?fxn or help(fxn) > ?round

10 Arrays

11 Matrices > (m*n)[2,4] > (m*n)[8] or

12 Conditional Execution: if Statements
Syntax: if (expr1) expr2 else expr3 Use logical operators in if statements: ==, >, <, <=, >=, <>

13 for Loops Syntax: for (name in expr1) expr2

14 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

15 while Loops Syntax: while (condition) expr

16 Expression is repeated until break is called
repeat Loops Syntax: repeat expr Expression is repeated until break is called

17 Getting Data from a File

18

19

20 Selecting Columns

21

22 Data source can also be on web

23 Extending R Via user-created packages available from repositories
CRAN (Comprehensive R Archive Network) Bioconductor

24 Installing and using Packages
Use GUI to select mirror, select package and install package 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 After installing use library() or GUI to load packages prior to use. Use search() to view active packages.

25 Using Packages Rectangular projection Bonne equal-area projection

26 U.S. Census State Boundaries
Results from Georeferencing

27 Filtering Data Use logical operators in filter expression: ==, >, <, <=, >=, <> StateProvince==“Missouri”

28 Editing records in your data frame

29 More Information


Download ppt "> Introduction to Nelson Rios, Tulane University"

Similar presentations


Ads by Google