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,

Slides:



Advertisements
Similar presentations
Programming for Beginners
Advertisements

Guy Griffiths. General purpose interpreted programming language Widely used by scientists and programmers of all stripes Supported by many 3 rd -party.
Introduction to R Brody Sandel. Topics Approaching your analysis Basic structure of R Basic programming Plotting Spatial data.
R for Macroecology Aarhus University, Spring 2011.
Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation.
 Statistics package  Graphics package  Programming language  Can be used to share/reproduce analyses  Many new packages being created - can be downloaded.
Introduction to GTECH 201 Session 13. What is R? Statistics package A GNU project based on the S language Statistical environment Graphics package Programming.
The Binary Machine Modern high-level programming languages are designed to make programming easier. On the other end, the low level, all modern digital.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
Introduction to a Programming Environment
Lecture 2 LISAM. Statistical software.. LISAM What is LISAM? Social network for Creating personal pages Creating courses  Storing course materials (lectures,
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Course: Introduction to Computers
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Python. What is Python? A programming language we can use to communicate with the computer and solve problems We give the computer instructions that it.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Visual Displays of Data and Basic Descriptive Statistics
1 Software Development Topic 2 Software Development Languages and Environments.
Topics Introduction Hardware and Software How Computers Store Data
Hands-on Introduction to R. Outline R : A powerful Platform for Statistical Analysis Why bother learning R ? Data, data, data, I cannot make bricks without.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Lecture 4 MATLAB Windows Arithmetic Operators Maintenance Functions
Programming 1 1. Introduction to object oriented programming and problem-solving.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
Intro to R R is a free version of S-plus R is a free version of S-plus Can be used interactively but script or syntax files are commonly used to record.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
CMPD 434 MULTIMEDIA AUTHORING Chapter 06 Multimedia Authoring Process IV.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 13: An Introduction to C++
Introduction to Engineering MATLAB – 6 Script Files - 1 Agenda Script files.
Eng Ship Structures 1 Introduction to Matlab.
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
Just as there are many human languages, there are many computer programming languages that can be used to develop software. Some are named after people,
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Basic of Programming Language Skill Area Computer System Computer Program Programming Language Programmer Translators.
Outline Comparison of Excel and R R Coding Example – RStudio Environment – Getting Help – Enter Data – Calculate Mean – Basic Plots – Save a Coding Script.
File Input and Output July 2nd, Inputs and Outputs Inputs Keyboard Mouse storage(hard drive) Networks O utputs Graphs Images Videos(image stacks)
I Power Higher Computing Software Development Development Languages and Environments.
Topic #1: Introduction EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
OCR GCSE Computing © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 1: Introduction.
Introduction to R Introductions What is R? RStudio Layout Summary Statistics Your First R Graph 17 September 2014 Sherubtse Training.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
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,
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Software Engineering Algorithms, Compilers, & Lifecycle.
Working with data in R 2 Fish 552: Lecture 3. Recommended Reading An Introduction to R (R Development Core Team) –
Software Development Languages and Environments. Computer Languages Just as there are many human languages, there are many computer programming languages.
Physics 114: Lecture 1 Overview of Class Intro to MATLAB
Introduction to Computers
Basic Concepts: computer, program, programming …
Why don’t programmers have to program in machine code?
Development Environment
Programming in R Intro, data and programming structures
Topics Introduction Hardware and Software How Computers Store Data
Introduction Osborn.
Choice of Programming Language
CS190/295 Programming in Python for Life Sciences: Lecture 1
Lab 1 Introductions to R Sean Potter.
Introduction to Computers
Use of Mathematics using Technology (Maltlab)
Code is on the Website Outline Comparison of Excel and R
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Matlab Basics Tutorial
IS 135 Business Programming
Introduction to Computer Science
Presentation transcript:

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, MATLAB, Python, Perl, R and/or Mathematica Data collection and analysis very important in Forensic Science since NAS 2009 Using the above languages, codes can easily be made available for review/discovery Why Leaning Programing?

All machines understand is on/off! High/low voltage High/low current High/low charge 1/0 binary digits (bits) To make a computer do anything, you have to speak machine language to it: Getting a computer to do anything useful Add 1 and 2. Store the result. Wikipedia

Machine language is not intuitive and can vary a great deal over designs The basic operations operations however are the same, e.g.: Move data here Combine these values Store this data Etc. “Human readable” language for basic machine operations: assembly language Getting a computer to do anything useful

Assembly is still cumbersome for (most) humans Getting a computer to do anything useful MOV AL, 61h Assembly A machine encoding Move the number 97 over to “storage area” AL

Better yet is a more “Englishy”, “high-level” language Enter: C, C++, Fortran, Java, … Higher level languages like these are translated (“compiled”) to machine language Not exactly true for Java, but it’s something analogous… Getting a computer to do anything useful

Even more “Englishy” and “high-level” are interpreted languages Enter: R MATLAB, Perl, Python, Mathematica, Maple, … The “code” of these languages are “interpreted” as commands by a program that is already running They make many assumptions behind the scenes Much easier to program with Much slower than compiled languages Getting a computer to do anything useful

R is not a black box! Codes available for review; totally transparent! R maintained by a professional group of statisticians, and computational scientists From very simple to state-of-the-art procedures available Very good graphics for exhibits and papers R is extensible (it is a full scripting language) Coding/syntax similar to Python and MATLAB Easy to link to C/C++ routines Why ?

Where to get information on R : R: Just need the base RStudio: A great IDE for R Work on all platforms Sometimes slows down performance… CRAN: Library repository for R Click on Search on the left of the website to search for package/info on packages Why ?

Finding our way around R/RStudio Script Window Command Line

Basic Input and Output Handy Commands: x <- 4 x <- “text goes in quotes” variables: store information Numeric input Text (character) input :Assignment operator

Get help on an R command: If you know the name: ?command name ?plot brings up html on plot command If you don’t know the name: Use Google (my favorite) ??key word Handy Commands:

R is driven by functions: Handy Commands: func(arguement1, argument2) x <- func(arg1, arg2) function name input to function goes in parenthesis function returns something; gets dumped into x

Input from Excel Save spreadsheet as a CSV file Use read.csv function Needs the path to the file Handy Commands: "/Users/npetraco/latex/papers/data.csv” Mac e.g.: “C:\Users\npetraco\latex\papers\data.csv” Windows e.g.: *Exercise: basicIO.R

Matrices: X X[,1] returns column 1 of matrix X X[3,] returns row 3 of matrix X Handy functions for data frames and matrices: dim, nrow, ncol, rbind, cbind User defined functions syntax: func.name <- function(arguements) { do something return(output) } To use it: func.name(values) Handy Commands:

User defined function example: Compute the intensities of the Planck distribution Let the user input a Temperature Let the user input endpoint. Assume it is in nm Careful here. Make sure wavelength units are consistent with the other constants. What is the “easiest” thing to do?? Handy Commands:

Hints: Have the user set the wavenumber range and generate a sequence from it: The “wavenumber axis” Handy Commands: nut <- seq(from=nut.min, to=nut.max, length.out=2500)