Introduction to R Lecture 1: Getting Started Andrew Jaffe 8/30/10.

Slides:



Advertisements
Similar presentations
create an APA-style title page using Microsoft Word 2007
Advertisements

Introduction to S-Plus by Francesco Ferretti Analysis of Biological Data Course Winter term 2007 Dalhousie University.
KompoZer. This is what KompoZer will look like with a blank document open. As you can see, there are a lot of icons for beginning users. But don't be.
Html: getting started HTML is hyper text markup language. It is what web browsers look at on the Internet. HTML documents should be created in a simple.
TS 313 Multimedia Applications Welcome to TS 313 Multimedia Applications There is no audio lecture associated with this set of introduction slides Refer.
 Statistics package  Graphics package  Programming language  Can be used to share/reproduce analyses  Many new packages being created - can be downloaded.
Purchasing Goods and Services. Overview In this session you will learn how to utilize the eProcurement Module to create requisitions for purchasing goods.
Calendar Browser is a groupware used for booking all kinds of resources within an organization. Calendar Browser is installed on a file server and in a.
Introduction to GTECH 201 Session 13. What is R? Statistics package A GNU project based on the S language Statistical environment Graphics package Programming.
Example Presentation Something to Show. Basic Title & Content Point to be made Number One Point to be made Number Two Point to be made Number Three.
MATLAB Extras Week 16 – 5/12/09 Kate Musgrave
CIS101 Introduction to Computing Week 05. Agenda Your questions CIS101 Survey Introduction to the Internet & HTML Online HTML Resources Using the HTML.
CIS101 Introduction to Computing
Creating and Publishing Your own website
How to Open Microsoft Word Click Start Click All Programs Click Microsoft Office Click Microsoft Word 2013.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Introduction to R Statistical Software Anthony (Tony) R. Olsen USEPA ORD NHEERL Western Ecology Division Corvallis, OR (541)
8/17/2015CS346 PHP1 Module 1 Introduction to PHP.
Creating a Web Page HTML, FrontPage, Word, Composer.
CPSC 203 Introduction to Computers Tutorial 03 & 29 Jie (Jeff) Gao September 15 & 16.
Panorama High School E.G.P./ Training to Put Students’ Grades on the Website Wednesday, September 29,
ES 101. Module MS Front Page Tutorial and Web Hosting.
CS110/CS119 Introduction to Computing (Java)
ULI101 – XHTML Basics (Part II) What is Markup Language? XHTML vs. HTML General XHTML Rules Block Level XHTML Tags XHTML Validation.
Creating Web Pages Overview. Design – Start with a Purpose Before you start any web page, you need to design the website. The first question that should.
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.
Lecture 4 MATLAB Windows Arithmetic Operators Maintenance Functions
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
Introduction to R Clay Ford, StatLab September 11/12, 2013.
University of Sunderland CDM105 Session 5 Web Authoring Tools The past and present A history of web authoring tools and an overview of Macromedia Dreamweaver.
Using Html Basics, Text and Links. Objectives  Develop a web page using HTML codes according to specifications and verify that it works prior to submitting.
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
Copyright © 2013 MyGraphicsLab / Pearson Education STRUCTURE AND HTML TAGS MyGraphicsLab: Adobe Dreamweaver CS6 ACA Certification Preparation for Web Communication.
HTML Hyper Text Markup Language A simple introduction.
Web Page Creation Part I ST: Introduction to Web Interface Design Prof. Angela Guercio.
Introduction to HTML. Slide 1 Hard-Coding What is hard-coding? –Creating the page in a text editor just using HTML A Web designer should know how to hard-
Creating and Publishing Your own web site PC Version SEAS 001 Professor Ahmadi.
← Select Exchange Once logged in. ↓ click Join Course Icon.
BIT 115: Introduction To Programming Instructor: Mike Panitz
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
HTML: Hyptertext Markup Language Doman’s Sections.
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
EQ: How can we learn the basics of formatting a college research paper in Microsoft Word? Mini Unit: Typing a Paper Diogene Date: 4/20/2015 Course: ELA-Grade.
11/25/2015Slide 1 Scripts are short programs that repeat sequences of SPSS commands. SPSS includes a computer language called Sax Basic for the creation.
Introduction to R Introductions What is R? RStudio Layout Summary Statistics Your First R Graph 17 September 2014 Sherubtse Training.
C++ LANGUAGE TUTORIAL LESSON 1 –WRITING YOUR FIRST PROGRAM.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python Karsten Hokamp, PhD Genetics TCD, 03/11/2015.
Field Instruction Roster Presentation Angela Marocco, Project Manager
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.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
Practical Kinetics Exercise 0: Getting Started Objectives: 1.Install Python and IPython Notebook 2.print “Hello World!”
+ Publishing Your First Post USING WORDPRESS. + A CMS (content management system) is an application that allows you to publish, edit, modify, organize,
1 2/16/05CS120 The Information Era Chapter 4 Basic Web Page Construction TOPICS: Intro to HTML and Basic Web Page Design.
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.
NOTEPAD++ Lab 1 1 Hanin Abdulrahman. Downloading Hanin Abdulrahman 2  Click here to downlaod Notepad++.here  For Mac users, try Textmate or Textwrangler.
Chris Knight Beginners’ workshop.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
JavaScript Part 1 Introduction to scripting The ‘alert’ function.
Development Environment
Lecture 2: Introduction to R
Getting Started with R.
2017年6月4日更新 1. イントロダクション 東北大学 大学院工学研究科 嶋田 慶太.
Intro to PHP & Variables
Use of Mathematics using Technology (Maltlab)
Module 1 Introduction to PHP 11/30/2018 CS346 PHP.
The Laptop Instrument Meeting 2 January 22, 2018.
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Guide: Report results Version of Ladok by the latest update:
A brief introduction to the nutrient tool-kit, getting R Studio to work and checking the data Martyn Kelly
Intro to Programming (in JavaScript)
Presentation transcript:

Introduction to R Lecture 1: Getting Started Andrew Jaffe 8/30/10

Lecture 1 Course overview What is R? Installing R Installing a text editor Interfacing text editor with R Writing scripts Using R as a calculator

About the Course Series of 7 seminars Covers the usage of R –Platform for beginning analyses –NOT covering statistics –Good programming etiquette Bring your laptop – there will be breaks to allow you to practice the code

About the Course This seminar is 1 unit pass/fail To pass, attend 5 out of 7 seminars Very little outside work

About the Course Some learning objectives include: –Importing/exporting data –Data management –Performing calculations –Recoding variables –Producing graphics –Installing packages –Writing functions

About the Course Course communication via Lectures and code will be hosted on my webpage – htmlhttp:// html

About the Instructor 3 rd year PhD student in Genetic Epi program, concurrent MHS in Bioinformatics Learned R five years ago, been using regularly the last two

Lecture 1 Course overview What is R? Installing R Installing a text editor Interfacing text editor with R Writing scripts Using R as a calculator Assignment

What is R? R is a language and environment for statistical computing and graphics R is the open source implementation of the S language, which was developed by Bell laboratories R is both open source and open development

What is R? Pros: –Free –Tons of packages, very flexible –Multiple datasets at any given time Cons: –Much more “programming” oriented –Minimal interface These are my personal opinions

What is R? Often times, a good first step for data cleaning and manipulation Then, export data to STATA or SAS for Epi analyses

What is R? ConsoleScript

Lecture 1 Course overview What is R? Installing R Installing a text editor Interfacing text editor with R Writing scripts Using R as a calculator Assignment

Installing R

Installing R - Windows Windows: click “base” and download

Installing R - Windows Click the link to the latest build

Installing R - Mac Mac: click the latest package’s.pkg file

Installing R Double click the downloaded file Hit ‘next’ a few times Use default settings Finish installing

Lecture 1 Course overview What is R? Installing R Installing a text editor Interfacing text editor with R Writing scripts Using R as a calculator Assignment

Installing a Text Editor Windows: R’s built-in text editor is terrible –It’s essentially Window’s notepad –We will download a much better one Mac: R’s built-in text editor is sufficient –Color coding, signals parenthesis closing, etc –I suggest using this until you think you need a better one

Installing a Text Editor I prefer Notepad++: – –Download the current version: npp.5.7.Installer.exe npp.5.7.Installer.exe –Install on your computer using defaults

Installing a Text Editor

Lecture 1 Course overview What is R? Installing R Installing a text editor Interfacing text editor with R Writing scripts Using R as a calculator Assignment

Interfacing with R Scripts: documents that contain reproducible R code and functions that you can send to the console (and save) –Files are designated with the “.R” extension –You can “source” scripts (more later) Console: Type commands directly into the console –Good for looking at your data, trying things, and plotting

Interfacing with R - Mac Mac: File  New Script This opens the default text editor To send a line of code to the R console, press Apple+Enter when the cursor is anywhere on that line Highlight chunks of code and press Apple+Enter to send

Interfacing with R - Windows Using the default text editor, pressing Ctrl+R sends lines to the console However, we want to use Notepad++ We need to download one more thing…

Interfacing with R - Windows “NppToR”: Notepad++ to R It must be running when R and Notepad++ are open When properly configured, press F8 to send lines of code, or highlighted chunks, to the console I will help configure this after class today

Interfacing with R – Windows More detailed instructions for installing NppToR or/index.php?title=Installinghttp://sourceforge.net/apps/mediawiki/nppt or/index.php?title=Installing

Lecture 1 Course overview What is R? Installing R Installing a text editor Interfacing text editor with R Writing scripts Using R as a calculator Assignment

Writing Scripts The comment symbol is # (pound) in R Comment liberally - you should be able to understand a script after not seeing it for 6 months Lines of #’s are useful to separate sections Useful for designating headers

Writing Scripts ################# # Title: Demo R Script # Author: Andrew Jaffe # Date: 7/30/10 # Purpose: Demonstrate comments in R ################### # this is a comment, nothing to the right of it gets read # this # is still a comment – you can use many #’s as you want # sometimes you have a really long comment, like explaining what you # are doing for a step in analysis. Take it to a second line

Writing Scripts Some common etiquette: –You can use spaces (more generally “white space”) within functions and commands liberally as well –Try to keep a reasonable number of characters per column – many commands can be broken into multiple lines –More to come later…

Lecture 1 Course overview What is R? Installing R Installing a text editor Interfacing text editor with R Writing scripts Using R as a calculator Assignment

R as a Calculator The R console functions as full calculator Try to play around with it: +, -, /, * are add, subtract, multiply, and divide ^ or ** is power ( and ) work with order of operations

Lecture 1 Course overview What is R? Installing R Installing a text editor Interfacing text editor with R Writing scripts Using R as a calculator Assignment

The assignment… operator: assigning a value to a name R accepts two operators “<-” and “=“ –Ie: x=8 (remember whitespace!: x = 8, x <- 8) Variable names are case-sensitive –Ie: X and x are different Set x = 8, and try using calculator functions on x

Assignment ‘Assignment’ literally puts whatever is on the right side of the operator into your left- hand side variable –Note that although you can name variables anything, you might run into some issues naming things the same as default R functions  Np++ turns functions red/pink so you know…

Examples of assignment, introducing R data Enough to get R up and running if this is the only class you attend. We will see them in much more detail over the next three sessions

Assignment status <- c(“case”,”case”,”case”, “control”,”control”,”control”) status class(status) table(status) factor(status) [alternatively: status <- c(rep(“case”,3), rep(“control”,3))]

Assignment web <- “ code.R” code.R –class(web) –source(web) You also don’t have to save tables/data you find online to your disk (note read.table works for most things – below aren’t tables though) –scan(web, what=character(0), sep = "\n") –scan(“ what=character(0))

Assignment mat <- matrix(c(1,2,3,4), nrow = 2, ncol = 2, byrow = T) # this is sourced in class(mat) mat mat + mat mat * mat mat %*% mat

Assignment class(dat) # dat is also sourced in head(dat) table(dat$sex, dat$status) …To be continued…

Questions?