Introduction to R Introductions What is R? RStudio Layout Summary Statistics Your First R Graph 17 September 2014 Sherubtse Training.

Slides:



Advertisements
Similar presentations
Introduction to R Brody Sandel. Topics Approaching your analysis Basic structure of R Basic programming Plotting Spatial data.
Advertisements

Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
R for Macroecology Aarhus University, Spring 2011.
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
 Statistics package  Graphics package  Programming language  Can be used to share/reproduce analyses  Many new packages being created - can be downloaded.
CIS101 Introduction to Computing Week 05. Agenda Your questions CIS101 Survey Introduction to the Internet & HTML Online HTML Resources Using the HTML.
Lecture 2 LISAM. Statistical software.. LISAM What is LISAM? Social network for Creating personal pages Creating courses  Storing course materials (lectures,
How to Use the R Programming Language for Statistical Analyses Part I: An Introduction to R Jennifer Urbano Blackford, Ph.D. Department of Psychiatry Kennedy.
FIRST COURSE Creating Web Pages with Microsoft Office 2007.
CIS101 Introduction to Computing Week 06. Agenda Your questions Excel Exam during second hour Our status after the snow day Introduction to the Internet.
© 2010 IBM Corporation IBM Experience Modeler - Theme Editor Installing Python Image Library Presenter’s Name - Presenter’s Title DD Month Year.
Microsoft ® Office Word 2007 Training Mail Merge II: Use the Ribbon and perform a complex mail merge [Your company name] presents:
XP New Perspectives on Microsoft Access 2002 Tutorial 71 Microsoft Access 2002 Tutorial 7 – Integrating Access With the Web and With Other Programs.
Introduction to R Statistical Software Anthony (Tony) R. Olsen USEPA ORD NHEERL Western Ecology Division Corvallis, OR (541)
Browser Comparisons - Convenience Internet Explorer 8 & 9, Chrome 11 and Firefox 4 Searching, Convenience & Add-ons.
ATM 315 Environmental Statistics Course Goto Follow the link and then choose the desktop application.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
Tutorial 1 Getting Started with Adobe Dreamweaver CS3
Applications Software. Applications software is designed to perform specific tasks. There are three main types of application software: Applications packages.
Data, graphics, and programming in R 28.1, 30.1, Daily:10:00-12:45 & 13:45-16:30 EXCEPT WED 4 th 9:00-11:45 & 12:45-15:30 Teacher: Anna Kuparinen.
Introduction to R Part 2. Working Directory The working directory is where you are currently saving data in R. What is the current working directory?
Introduction to R Lecture 1: Getting Started Andrew Jaffe 8/30/10.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Lesson 1 Introduction.
Piotr Wolski Introduction to R. Topics What is R? Sample session How to install R? Minimum you have to know to work in R Data objects in R and how to.
Hands-on Introduction to R. We live in oceans of data. Computers are essential to record and help analyse it. Competent scientists speak C/C++, Java,
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
Outline Comparison of Excel and R R Coding Example – RStudio Environment – Getting Help – Enter Data – Calculate Mean – Basic Plots – Save a Coding Script.
R packages/libraries Data input/output Rachel Carroll Department of Public Health Sciences, MUSC Computing for Research I, Spring 2014.
1 ADVANCED MICROSOFT POWERPOINT Lesson 9 – Importing and Exporting Information Microsoft Office 2003: Advanced.
Chapter 3 MATLAB Fundamentals Introduction to MATLAB Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
MapInfo Professional 11.0: getting started Xiaogang (Marshall) Ma School of Science Rensselaer Polytechnic Institute Friday, January 25, 2013 GIS in the.
Introduction to EBSCOhost Tutorial support.ebsco.com.
Today’s Goals Answer questions about homework and lecture 2 Understand what a query is Understand how to create simple queries using Microsoft Access 2007.
PROGRAMMING IN R Introduction to R. In this session I will: Introduce you to the R program and windows Show how to install R Write basic programs in R.
Practical Kinetics Exercise 0: Getting Started Objectives: 1.Install Python and IPython Notebook 2.print “Hello World!”
Learn R Toolkit D Kelly O'DayInstall & SetupMod 1 - Setup: 1 Module 1 Installing & Setting Up R Do See & HearRead Learn PowerPoint must be in View Show.
Introduction to CADStat. CADStat and R R is a powerful and free statistical package [
1 Berger Jean-Baptiste
Chris Knight Beginners’ workshop.
C Copyright © 2009, Oracle. All rights reserved. Using SQL Developer.
Introduction to R Dr. Satish Nargundkar. What is R? R is a free software environment for statistical computing and graphics. It compiles and runs on a.
Statistical Exploratory Analysis with “EnQuireR” 1.Introduction 2.Installation 3.How to 4.Report.
Introduction to EBSCOhost
Block 1: Introduction to R
Lecture 2: Introduction to R
Eclipse Navigation & Usage.
Tutorial Introduction to support.ebsco.com.
Macrosystems EDDIE: Getting Started + Troubleshooting Tips
Windows Internet Explorer 7-Illustrated Essentials
Lab 1 Introductions to R Sean Potter.
Introduction to R.
ENDNOTE Software – The Basics
Introduction to EBSCOhost
Crash course in R – short introduction
Code is on the Website Outline Comparison of Excel and R
CSCI N207 Data Analysis Using Spreadsheet
Microsoft PowerPoint 2007 – Unit 2
Macrosystems EDDIE: Getting Started + Troubleshooting Tips
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Stata Basic Course Lab 2.
Introduction to EBSCOhost
Tutorial 7 – Integrating Access With the Web and With Other Programs
Amos Introduction In this tutorial, you will be briefly introduced to the student version of the SEM software known as Amos. You should download the current.
Macrosystems EDDIE: Getting Started + Troubleshooting Tips
Using R for Data Analysis and Data Visualization
Macrosystems EDDIE: Getting Started + Troubleshooting Tips
Tutorial Introduction to help.ebsco.com.
A brief introduction to the nutrient tool-kit, getting R Studio to work and checking the data Martyn Kelly
Presentation transcript:

Introduction to R Introductions What is R? RStudio Layout Summary Statistics Your First R Graph 17 September 2014 Sherubtse Training

Ellen Cheng

Your Turn  Name & department  Research or activities for which you might be using R in the future (i.e., why are you here?) [Compile group list]

What is ?... an open source programming language for statistical computing and graphics... with 5895 statistical “add-on” packages contributed by R-users since and an extensive online “help” community (internet discussion site)

(data from Wikipedia) Why Use R? Compatible with many operating systems

(data from Wikipedia) Why Use R? FREE!

(data from Wikipedia) Why Use R? Flexible & powerful statistical program

Why Use R? “R has really become the second language for people coming out of grad school now, and there’s an amazing amount of code being written for it” (Max Kuhn, Pfizer statistician) “The popularity of R at universities could threaten SAS Institute, the privately held business software company that specializes in data analysis software” (NY Times article, 6-Jan 2009) “Companies as diverse as Google, Pfizer, Merck, Bank of America, the InterContinental Hotels Group and Shell use [R]...Companies like Google and Pfizer say they use the [R] software for just about anything they can” (NY Times article, 6-Jan 2009)

Besides Statistics, What Can R Do? Publication-quality charts & graphs

Besides Statistics, What Can R Do? Publication-quality charts & graphs Dynamic graphing & animations

Besides Statistics, What Can R Do? Publication-quality charts & graphs Dynamic graphing & animations Link with many other applications, e.g., Google Earth, GIS, etc.... and many, MANY other things

Migratory path of a turkey vulture in 2009 (red), 2010 (blue), 2011 (green)

Abundance data for two different species (blue, red) plotted on Google Earth map

LET’S GET STARTED...

Installing R 1

2 Choose a CRAN mirror 3 Choose your Operating System 4 Choose ‘base’ installation 5 Download

Installing RStudio 1

2

3

RStudio Layout CONSOLE for typing code for immediate execution, and seeing output

RStudio Layout SOURCE PANE for writing and editing code (script) for later execution later (like a notepad), and a good way to store notes for this training

RStudio Layout - WORKSPACE tab shows active variables & data - HISTORY tab records all the code as you execute them

RStudio Layout - FILES tab shows files & folders in your workspace - PLOTS tab for viewing graphs - PACKAGES tab for installing & updating R packages - HELP tab for R help

CREATE FILES & SET YOUR CURRENT WORKING DIRECTORY

1 Browse to your working directory

2 Set your working directory

getwd() to see your current directory

WHAT IS A WORKING DIRECTORY? 1) Create a test script with variables – check global environment & history 2) Save the test script – where does it save? 3) Close RStudio, then open it from the script – what is the working directory? 4) Close RStudio, then open it from the application – what is the working directory? NOTE: Can also save workspace with a specific name (Session > Save Workspace As...)

TO SET A DEFAULT DIRECTORY... (if you just open RStudio from the application, this is the directory it will use) MAC: RStudio > Preferences WINDOWS: Tools > Global Options

RStudio Layout - FILES tab shows files & folders in your workspace - PLOTS tab for viewing graphs - PACKAGES tab for installing & updating R packages - HELP tab for R help

R Help

help.start() to access some R resources off-line help(topic_name) OR ?topic_name if the relevant package is loaded (use quotes for words with spaces) help.search(topic_name) OR ??topic_name if the package is not loaded

R Help

RStudio Layout - FILES tab shows files & folders in your workspace - PLOTS tab for viewing graphs - PACKAGES tab for installing & updating R packages - HELP tab for R help

Packages in this list are already installed. Mark boxes to load the ones you want to use. Now unload the package and type library(datasets) in the console

Quakes Dataset Read the documentation for this dataset – What do these data describe? – How many data records are there? – What are the 5 variables included in this dataset? Type the dataset name in the console Now try these functions (use your Source pane!): names(quakes) head(quakes) tail(quakes)

Quakes Dataset Examine how the history pane relates to the console, and use it to search & run previous commands (or up- arrow). How would you send commands to a script? Learn what these functions do: summary() ncol() nrow() dim() View()

Quakes Dataset Examine a single column of data: quakes$mag Calculate the mean and standard deviation of quake magnitudes ??”standard deviation” help.search(“standard deviation”)

Missing Values Missing values in your data should be entered as NA (not available)—not as blanks For some functions, you need to specify in function arguments what to do with missing values in the data (e.g., na.rm=TRUE) Use the function is.na() to determine if there are missing values in a data set What does sum(is.na()) tell us? Create the vector: x <- c(5, 10, 15, NA, 25)...then calculate the mean of the vector

Your First R Graph Quakes Dataset Is there a relationship between the magnitude of an earthquake and the number of stations reporting?  What kind of graph would we plot?  How would we expect the graph to look? Use plot() to create this graph (which package does this function belong to?)

plot (quakes$mag, quakes$stations) ALTERNATIVE CODE: with (quakes, plot (mag, stations)) How would you use with() to calculate the mean of quakes$mag?

Learn to Use Function Arguments Play around with sending arguments to the plot() function. For now, try: main="Fiji earthquakes since 1964" xlab="Magnitude" ylab="# of Stations Reporting" col="green" Then export the graph as a jpeg file & save it (easiest to resize before you export)

TODAY'S REVIEW How would you... list the first few records of a dataset see a dataset in Excel format find out the number of rows & columns in a dataset calculate the standard deviation of a vector get summary information on a dataset find out if there are missing values in a dataset

TODAY'S REVIEW How would you... find out the current working directory create a simple scatterplot list the column names for a dataset load a package find out the number of rows in a dataset calculate the mean of a vector