Basic R programming. Ana Teresa Maia DCBM / CBME
|
|
- Jonas Watkins
- 5 years ago
- Views:
Transcription
1 Basic R programming Ana Teresa Maia DCBM / CBME
2 Today Sources! Introduction Documentation and help Packages R Studio Basics and Syntax Data Types vectors; lists; data.frames; matrices R Programming Basic 25/06/12 Slide 2 of 62
3 Where did I get this from??!!! Thomas Girke, Stephen Eglen, on.action?uri=info:doi/ /journal.pcbi s001 BeniltonCarvalho, Simon Tavaré, and many others teaching at the Mphilin Computational Biology at the University of Cambridge R Programming Basic 25/06/12 Slide 3 of 62
4 Today Sources! Introduction Documentation and help Packages R Studio Basics and Syntax Data Types vectors; lists; data.frames; matrices R Programming Basic 25/06/12 Slide 4 of 62
5 Introduction to R Look and Feel of the R Environment R Library Depositories Getting Around Basic Syntax Data Types and Subsetting Basic Calculations Reading and Writing External Data Some Great R Functions Graphics Utilities R Programming Basic 25/06/12 Slide 5 of 62
6 What is R? Why use R? Computer language and complete statistical package which allows the user to program and use tools developed by others Efficient functions and data structures for data analysis Powerful graphics Support group and widely used Free, open source Versatile R Programming Basic 25/06/12 Slide 6 of 62
7 History S language came from Bell Labs (Becker, Chambers and Wilks). Commercial version S-plus (1988). R emerged as a combination of S and Scheme: Ross Ihakaand Robert Gentleman (NZ). 1993: first announcement. 1995: 0.60 release, now under GPL. Mar 30 th 2012: release Stable, multi-platform. Major release typically Apr/Oct with fixes between. R-core now 20 people, key academics in field, including John Chambers. R Programming Basic 25/06/12 Slide 7 of 62
8 Today Sources! Introduction Documentation and help Packages R Studio Basics and Syntax Data Types vectors; lists; data.frames; matrices R Programming Basic 25/06/12 Slide 8 of 62
9 Documentation and on-line help Introductory Statistics with R (Springer, Dalgaard). A first course in statistical programming with R (CUP, Braun and Murdoch). Computational Genome Analysis: An Introduction (Springer, Deonier, Tavaréand Waterman). R programming for Bioinformatics (CRC Press,Gentleman). R-help mailing list. Bioinformatics and Computational Biology Solutions Using R and Bioconductor(John Verzani, 2004) UCR Manual (Thomas Girke) A beginners guide to R (Springer, Zuur, Ieno, Meesters) Alot of material placed in the MSc folder in Google Docs R Programming Basic 25/06/12 Slide 9 of 62
10 Package Directories CRAN(>3000 packages) general data analysis BioConductor(>500 packages) bioscience data analysis Omegahat(>30 packages) programming interfaces R Programming Basic 25/06/12 Slide 10 of 62
11 Today Sources! Introduction Documentation and help Packages R Studio Basics and Syntax Data Types vectors; lists; data.frames; matrices R Programming Basic 25/06/12 Slide 11 of 62
12 The R look! R Gui: OS X R Gui: Windows Command-line R: Linux/OS X R Programming Basic 25/06/12 Slide 12 of 62
13 RStudio: Alternative Working Environment for R Integrated development environment (IDE) that works well for beginners and developers R Programming Basic 25/06/12 Slide 13 of 62
14 Today Sources! Introduction Documentation and help Packages R Studio Basics and Syntax Data Types vectors; lists; data.frames; matrices R Programming Basic 25/06/12 Slide 14 of 62
15 Aim This course aims to teach R as a general-purpose programming language. Topics to be mastered in this course include: Interactive use of R. Basic data types: vector, matrix, list, data.frame, factor, character. Writing scripts. Graphical facilities. File input/output. Vectorization. Numerics issues. R Programming Basic 25/06/12 Slide 15 of 62
16 Startup/Closing Starting R The R GUI versions under Windows and Mac OS X can be opened by doubleclicking their icons. Alternatively, one can start it by typing R in a terminal (default under Linux). Startup/Closing Behavior The R environment is controlled by hidden files in the startup directory:.rdata,.rhistoryand.rprofile(optional). History means you can automatically save all commands you type Rdata saves everything in memory (can be large- be careful) Best to rename these using save.image(file= S01_GeneProjectMay2012.RData ) save(myvec, file= S01_GeneProjectMay2012.RData ) savehistory(file= S01_GeneProjectMay2012.Rhistory ) R Programming Basic 25/06/12 Slide 16 of 62
17 Startup/Closing Closing R (Note) ## Closing R > q() Save workspace image? [y/n/c]: When responding with y, then the entire R workspace will be written to the.rdatafile which can become very large. Often it is sufficient to just save an analysis protocol in an R source file. This way one can quickly regenerate all data sets and objects. R Programming Basic 25/06/12 Slide 17 of 62
18 Basic Location Create an object with the assignment operator <- (or = ) > object <-... List objects in current R session > ls() Return content of current working directory > dir() Return path of current working directory > getwd() [1]"/Users/atmaia" Change current working directory > setwd("/home/user") # change to a new folder named BioComp2012 R Programming Basic 25/06/12 Slide 18 of 62
19 Basic Location Create an object with the assignment operator <- (or = ) > object <-... List objects in current R session > ls() Return content of current working directory > dir() Return path of current working directory > getwd() [1]"/Users/atmaia" Change current working directory > setwd("/home/user") R Programming Basic 25/06/12 Slide 19 of 62
20 Basic Syntax General R command syntax > object <-function(arguments) > object <-object[arguments] Execute an R script > source("my script.r") Execute an R script from command-line $ R CMD BATCH my script.r $ R --slave < my script.r Save scripts S01_xxxDate.R, S02_xxxDate.R, etc where xxx is project name R Programming Basic 25/06/12 Slide 20 of 62
21 Basic Syntax Finding help >?function Load a library > library("my_library") Summary of all functions within a library > library(help="my_library") Load library manual (PDF file) > vignette() R Programming Basic 25/06/12 Slide 21 of 62
22 Example -Package Documentation Suppose we are interested in making a flow chart. After browsing the list of contributed packages on the R website we decide to use diagram. First download, install and load the package diagram > install.packages("diagram") > library(diagram) List of functions with brief descriptions in the diagram package > help(package=diagram) View the vignette > vignette("diagram") Look at the documentation for the function plotmat() >?plotmat R Programming Basic 25/06/12 Slide 22 of 62
23 Getting Data into R Simple Excel SpreadSheet data Simple table read.table() read.csv() scan() Some common data types Microarray SNP NGS R Programming Basic 25/06/12 Slide 23 of 62
24 Getting Data into R Reading Affymetrix Data library(affy) require(affy) # Alternative affybatch <- ReadAffy(celfile.path="[Location of your data]") eset<-justrma() R Programming Basic 25/06/12 Slide 24 of 62
25 Reading and Writing External Data Import Data into R > read.delim("mydata.xls", sep="\t") > Survival_TP53 <-read.table("/volumes/ /Survival.txt", sep="\t", header=t) Export Data from R to File > write.table(myframe, file="myfile.xls", sep="\t", quote=f) R Programming Basic 25/06/12 Slide 25 of 62
26 Basic Operators and Calculations Comparison operators: ==,! =, <, >, <=, >= Example: > 1==1 Logical operators: AND: &, OR:, NOT:! Example: > x <-1:10 >y <-10:1 >x>y & x>5 Calculations: Example: > x + y; sum(x); mean(x); sd(x); sqrt(x) > apply(iris[,1:3], 1, mean) R Programming Basic 25/06/12 Slide 26 of 62
27 options() The function options() sets several global options that affect how R computes and displays results. To look at the value of a single option, getoption ("option name") Options reset to the defaults with each new R session, even if you save the workspace. For example suppose we want to change the maximum number of digits printed from 7 (default) to 15. > defaults <- options() # Save all default options > getoption("digits") [1] 7 > pi [1] > options(digits=15) # Change to 15 digits > pi [1] > options(defaults) # Restore all default options > getoption("digits") [1] 7 R Programming Basic 25/06/12 Slide 27 of 62
28 options() The function options() sets several global options that affect how R computes and displays results. To look at the value of a single option, getoption ("option name") Options reset to the defaults with each new R session, even if you save the workspace. For example suppose we want to change the maximum number of digits printed from 7 (default) to 15. > defaults <- options() # Save all default options > getoption("digits") [1] 7 > pi [1] > options(digits=15) # Change to 15 digits > pi [1] > options(defaults) # Restore all default options > getoption("digits") [1] 7 R Programming Basic 25/06/12 Slide 28 of 62
29 Today Sources! Introduction Documentation and help Packages R Studio Basics and Syntax Data Types vectors; lists; data.frames; matrices R Programming Basic 25/06/12 Slide 29 of 62
30 Data Types A vector contains an indexed set of values that are all of the same type: Logical (ex. TRUE, FALSE) Numeric (ex. 1,2,3 ) Complex (ex. 1,b,3) Character (ex. "a","b","c") The numeric type can be further broken into integer, single and double types R Programming Basic 25/06/12 Slide 30 of 62
31 Data Structures vector elements of the same type factor categorical list can contain objects of different types matrix table of numbers data.frame table of numbers and/or characters environment- hashtable functional R Programming Basic 25/06/12 Slide 31 of 62
32 Data Structures There is no need to declare the types of the variables > x <- c(1,2,3,4,5,6) > class(x) [1] "numeric" y<-10 > class(y) [1] "numeric" > z<- "a string" > class(z) [1] "character R Programming Basic 25/06/12 Slide 32 of 62
33 Data Structures There is no need to declare the types of the variables > x <- c(1,2,3,4,5,6) > class(x) [1] "numeric" y<-10 > class(y) [1] "numeric" > z<- "a string" > class(z) [1] "character R Programming Basic 25/06/12 Slide 33 of 62
34 > t<- data.frame(type=c(rep("case",2),rep("control",3),time=rnorm(5))) > t type 1 case 2 case 3 control 4 control 5 control > class(t) [1] "data.frame R Programming Basic 25/06/12 Slide 34 of 62
35 > t<- data.frame(type=c(rep("case",2),rep("control",3),time=rnorm(5))) > t type 1 case 2 case 3 control 4 control 5 control > class(t) [1] "data.frame R Programming Basic 25/06/12 Slide 35 of 62
36 Creating Vectors Two symbols can be used for assignment <-and = > x <- c(1,2,3,4,5,6) > x [1] > s="a flower" > s [1] "a flower" > a <- seq.int(5) ## fast for integers > a [1] R Programming Basic 25/06/12 Slide 36 of 62
37 Creating Vectors Two symbols can be used for assignment <-and = > x <- c(1,2,3,4,5,6) > x [1] > s="a flower" > s [1] "a flower" > a <- seq.int(5) ## fast for integers > a [1] R Programming Basic 25/06/12 Slide 37 of 62
38 Functions for Creating Vectors c concatenate :-integer sequence seq general sequence rep repetitive patterns vector vector of given length with default value R Programming Basic 25/06/12 Slide 38 of 62
39 Functions for Creating Vectors > seq(1,6) [1] > seq(from=100, by=1, length=5) [1] > 1:6 [1] > rep(1:2,3) [1] > vector(mode="character", length=5) [1] "" "" "" "" "" > vector(mode="logical", length=5) [1] FALSE FALSE FALSE FALSE FALSE R Programming Basic 25/06/12 Slide 39 of 62
40 Functions for Creating Vectors > seq(1,6) [1] > seq(from=100, by=1, length=5) [1] > 1:6 [1] > rep(1:2,3) [1] > vector(mode="character", length=5) [1] "" "" "" "" "" > vector(mode="logical", length=5) [1] FALSE FALSE FALSE FALSE FALSE R Programming Basic 25/06/12 Slide 40 of 62
41 Functions for Creating Vectors > good <- seq(from=100, by=1, length=5) [1] >bad<-(1:3) > good[-bad] ## exclude elements [1] R Programming Basic 25/06/12 Slide 41 of 62
42 Functions for Creating Vectors > good <- seq(from=100, by=1, length=5) [1] >bad<-(1:3) > good[-bad] ## exclude elements [1] R Programming Basic 25/06/12 Slide 42 of 62
43 VectorizedArithmetic Most arithmetic operations in the R language are vectorized, i.e. the operation is applied element-wise > 1:3+10:12 [1] > 1:3 [1] When one operand is shorter than the other it is recycled > rep(1:2, 3) [1] R Programming Basic 25/06/12 Slide 43 of 62
44 VectorizedArithmetic Most arithmetic operations in the R language are vectorized, i.e. the operation is applied element-wise > 1:3+10:12 [1] > 1:3 [1] When one operand is shorter than the other it is recycled > rep(1:2, 3) [1] R Programming Basic 25/06/12 Slide 44 of 62
45 Naming indexes of a vector > joe< c(24, 1.70) > joe > names( joe) > names( joe) < c( age, height ) > joe > joe[ height ] == joe[2] Referingto index by name rather than by position can make code more readable, and flexible. Cannot do things like x [1:4] easily though, since you need to name all four elements you want. Note: in second use of names()above, we are actually using the replacement function names<, see later. R Programming Basic 25/06/12 Slide 45 of 62
46 Common functions for vectors length() rev() sum(), cumsum(), prod(), cumprod() mean(), sd(), var(), median() min(), max(), range(), summary() exp(), log(), sin(), cos(), tan() [radians, not degrees] round(), ceil(), floor(), signif() sort(), order(), rank() which(), which.max() any(), all() R Programming Basic 25/06/12 Slide 46 of 62
47 Common functions for vectors Functions can be called within function calls; the following are equivalent: x < c(3, 2, 9, 4) y < exp(x); z1 < which(y > 20) ## case 1 z2 < which ( exp(x) > 20) ## case 2 all.equal(z1, z2) R Programming Basic 25/06/12 Slide 47 of 62
48 Matrices and Arrays Can be created using matrix and array Vectors with dimension attribute > x<-matrix(1:10, nrow=2) > dim(x) [1] 2 5 > x [,1] [,2] [,3] [,4] [,5] [1,] [2,] > as.vector(x) [1] R Programming Basic 25/06/12 Slide 48 of 62
49 Matrices and Arrays Can be created using matrix and array Vectors with dimension attribute > x<-matrix(1:10, nrow=2) > dim(x) [1] 2 5 > x [,1] [,2] [,3] [,4] [,5] [1,] [2,] > as.vector(x) [1] R Programming Basic 25/06/12 Slide 49 of 62
50 Lists Ordered set of elements that can be arbitrary R objects (vectors, functions, etc) Can be heterogeneous > lst = list(a=1:3, b="olá", c=sqrt) > lst $a [1] $b [1] "olá" $c function (x).primitive("sqrt") > lst$c(49) [1] 7 R Programming Basic 25/06/12 Slide 50 of 62
51 Lists Ordered set of elements that can be arbitrary R objects (vectors, functions, etc) Can be heterogeneous > lst = list(a=1:3, b="olá", c=sqrt) > lst $a [1] $b [1] "olá" $c function (x).primitive("sqrt") > lst$c(49) [1] 7 R Programming Basic 25/06/12 Slide 51 of 62
52 Environments Differ from list because they have no order All objects are stored by name Names must match exactly > e1=new.env() > e1[["a"]] <- 1:3 > assign("b", "olá", e1) > ls(e1) [1] "a" "b" R Programming Basic 25/06/12 Slide 52 of 62
53 Data Frames Special structure in R Used to hold a set of spreadsheetlike tables data.frame, the observations are the rows and the covariates the columns Can be treated like matrices Columns are vectors, but different columns can be vectors of different types Are in fact lists, and list subsettingcan also be used on them R Programming Basic 25/06/12 Slide 53 of 62
54 Data Frames > df <-data.frame(type=rep(c("case","control"),c(2,3)),time=rexp(5)) > df type time 1 case case control control control > df$time [1] R Programming Basic 25/06/12 Slide 54 of 62
55 Data Frames > df <-data.frame(type=rep(c("case","control"),c(2,3)),time=rexp(5)) > df type time 1 case case control control control > df$time [1] R Programming Basic 25/06/12 Slide 55 of 62
56 General SubsettingRules Subsettingby indices > myvec<-1:26; names(myvec) <-LETTERS > myvec[1:4] Subsettingby same length logical vectors > mylog<-myvec> 10 > myvec[mylog] Subsettingby field names > myvec[c("b", "K","M")] Special case > iris$species R Programming Basic 25/06/12 Slide 56 of 62
57 Some Great R Functions The unique() function to make vector entries unique > unique(iris$sepal.length); length(unique(iris$sepal.length)) The table()function counts the occurrences of entries > table(iris$species) The aggregate()function computes statistics of data aggregates > aggregate(iris[,1:4], by=list(iris$species), FUN=mean, na.rm=t) The %in% function returns the intersect between two vectors > month.name[month.name%in% c("may", "July")] The merge()function joins data frames based on a common key column > merge(frame1, frame2, by.x=1, by.y=1, all = TRUE) R Programming Basic 25/06/12 Slide 57 of 62
58 Bugs Common Bugs and Fixes Syntax Error Trailing + Error When Performing Operations R Programming Basic 25/06/12 Slide 58 of 62
59 Error: syntax error Possible causes: Incorrect spelling (of the function, variable, etc.) Including a "+" when copying code from the Console Having an extra parenthesis at the end of a function Having an extra bracket when subsetting R Programming Basic 25/06/12 Slide 59 of 62
60 Trailing + Possible causes: Not closing a function call with a parenthesis Not closing brackets when subsetting Not closing a function you wrote with a squiggly brace R Programming Basic 25/06/12 Slide 60 of 62
61 Error in...: requires numeric matrix/vector arguments Possible causes: 1. Objects are data frames, not matrices 2. Elements of the vectors are characters Possible solutions: 1. Coerce (a copy of) the data set to be a matrix, with the as.matrix() command 2. Coerce (a copy of) the vector to have numeric entries, with the as.numeric() command R Programming Basic 25/06/12 Slide 61 of 62
62 Example -Sample Script # Calculate the mean of x x = c(0,5,7,9,1,2,8) mean(x) # How and how not to wrap expressions long.variable.name <- 5 really.long.variable.name <- 7 # R views the first line as a complete expression. Thus the code is # treated as two separate expressions instead of one long expression. long.answer.name <- 500*factorial(long.variable.name) + sqrt(really.long.variable.name) # Here the first line is not a complete expression (trailing + sign) so # R continues reading lines of code until the expression is complete long.answer.name <- 500*factorial(long.variable.name) + sqrt(really.long.variable.name) # Writing two expressions on the same line requires a ; mean(x); var(x) R Programming Basic 25/06/12 Slide 62 of 62
Introduction into R. A Short Overview. Thomas Girke. December 8, Introduction into R Slide 1/21
Introduction into R A Short Overview Thomas Girke December 8, 212 Introduction into R Slide 1/21 Introduction Look and Feel of the R Environment R Library Depositories Installation Getting Around Basic
More informationBioinformatics Workshop - NM-AIST
Bioinformatics Workshop - NM-AIST Day 2 Introduction to R Thomas Girke July 24, 212 Bioinformatics Workshop - NM-AIST Slide 1/21 Introduction Look and Feel of the R Environment R Library Depositories Installation
More informationIntroduction to R. UCLA Statistical Consulting Center R Bootcamp. Irina Kukuyeva September 20, 2010
UCLA Statistical Consulting Center R Bootcamp Irina Kukuyeva ikukuyeva@stat.ucla.edu September 20, 2010 Outline 1 Introduction 2 Preliminaries 3 Working with Vectors and Matrices 4 Data Sets in R 5 Overview
More informationIntroduction to R. Nishant Gopalakrishnan, Martin Morgan January, Fred Hutchinson Cancer Research Center
Introduction to R Nishant Gopalakrishnan, Martin Morgan Fred Hutchinson Cancer Research Center 19-21 January, 2011 Getting Started Atomic Data structures Creating vectors Subsetting vectors Factors Matrices
More informationAn Introduction to R- Programming
An Introduction to R- Programming Hadeel Alkofide, Msc, PhD NOT a biostatistician or R expert just simply an R user Some slides were adapted from lectures by Angie Mae Rodday MSc, PhD at Tufts University
More informationUsing R for statistics and data analysis
Introduction ti to R: Using R for statistics and data analysis BaRC Hot Topics October 2011 George Bell, Ph.D. http://iona.wi.mit.edu/bio/education/r2011/ Why use R? To perform inferential statistics (e.g.,
More informationWhy use R? Getting started. Why not use R? Introduction to R: It s hard to use at first. To perform inferential statistics (e.g., use a statistical
Why use R? Introduction to R: Using R for statistics ti ti and data analysis BaRC Hot Topics November 2013 George W. Bell, Ph.D. http://jura.wi.mit.edu/bio/education/hot_topics/ To perform inferential
More informationIntroduction to R. Educational Materials 2007 S. Falcon, R. Ihaka, and R. Gentleman
Introduction to R Educational Materials 2007 S. Falcon, R. Ihaka, and R. Gentleman 1 Data Structures ˆ R has a rich set of self-describing data structures. > class(z) [1] "character" > class(x) [1] "data.frame"
More informationIntroduction to R: Using R for statistics and data analysis
Why use R? Introduction to R: Using R for statistics and data analysis George W Bell, Ph.D. BaRC Hot Topics November 2014 Bioinformatics and Research Computing Whitehead Institute http://barc.wi.mit.edu/hot_topics/
More informationWhy use R? Getting started. Why not use R? Introduction to R: Log into tak. Start R R or. It s hard to use at first
Why use R? Introduction to R: Using R for statistics ti ti and data analysis BaRC Hot Topics October 2011 George Bell, Ph.D. http://iona.wi.mit.edu/bio/education/r2011/ To perform inferential statistics
More informationIntroduction to R statistical environment
Introduction to R statistical environment R Nano Course Series Aishwarya Gogate Computational Biologist I Green Center for Reproductive Biology Sciences History of R R is a free software environment for
More informationIntroduction to R: Using R for statistics and data analysis
Why use R? Introduction to R: Using R for statistics and data analysis George W Bell, Ph.D. BaRC Hot Topics November 2015 Bioinformatics and Research Computing Whitehead Institute http://barc.wi.mit.edu/hot_topics/
More informationProgramming with R. Educational Materials 2006 S. Falcon, R. Ihaka, and R. Gentleman
Programming with R Educational Materials 2006 S. Falcon, R. Ihaka, and R. Gentleman 1 Data Structures ˆ R has a rich set of self-describing data structures. > class(z) [1] "character" > class(x) [1] "data.frame"
More informationProgramming with R. Educational Materials 2006 S. Falcon, R. Ihaka, and R. Gentleman
Programming with R Educational Materials 2006 S. Falcon, R. Ihaka, and R. Gentleman 1 Data Structures ˆ R has a rich set of self-describing data structures. > class(z) [1] "character" > class(x) [1] "data.frame"
More informationIntroduction to R. Course in Practical Analysis of Microarray Data Computational Exercises
Introduction to R Course in Practical Analysis of Microarray Data Computational Exercises 2010 March 22-26, Technischen Universität München Amin Moghaddasi, Kurt Fellenberg 1. Installing R. Check whether
More informationMails : ; Document version: 14/09/12
Mails : leslie.regad@univ-paris-diderot.fr ; gaelle.lelandais@univ-paris-diderot.fr Document version: 14/09/12 A freely available language and environment Statistical computing Graphics Supplementary
More informationPOL 345: Quantitative Analysis and Politics
POL 345: Quantitative Analysis and Politics Precept Handout 1 Week 2 (Verzani Chapter 1: Sections 1.2.4 1.4.31) Remember to complete the entire handout and submit the precept questions to the Blackboard
More informationDescription/History Objects/Language Description Commonly Used Basic Functions. More Specific Functionality Further Resources
R Outline Description/History Objects/Language Description Commonly Used Basic Functions Basic Stats and distributions I/O Plotting Programming More Specific Functionality Further Resources www.r-project.org
More informationMBV4410/9410 Fall Bioinformatics for Molecular Biology. Introduction to R
MBV4410/9410 Fall 2018 Bioinformatics for Molecular Biology Introduction to R Outline Introduce R Basic operations RStudio Bioconductor? Goal of the lecture Introduce you to R Show how to run R, basic
More informationR Short Course Session 1
R Short Course Session 1 Daniel Zhao, PhD Sixia Chen, PhD Department of Biostatistics and Epidemiology College of Public Health, OUHSC 10/23/2015 Outline Overview of the 5 sessions Pre-requisite requirements
More informationIntroduction to R: Using R for Statistics and Data Analysis. BaRC Hot Topics
Introduction to R: Using R for Statistics and Data Analysis BaRC Hot Topics http://barc.wi.mit.edu/hot_topics/ Why use R? Perform inferential statistics (e.g., use a statistical test to calculate a p-value)
More informationAn introduction to R WS 2013/2014
An introduction to R WS 2013/2014 Dr. Noémie Becker (AG Metzler) Dr. Sonja Grath (AG Parsch) Special thanks to: Dr. Martin Hutzenthaler (previously AG Metzler, now University of Frankfurt) course development,
More informationComputer lab 2 Course: Introduction to R for Biologists
Computer lab 2 Course: Introduction to R for Biologists April 23, 2012 1 Scripting As you have seen, you often want to run a sequence of commands several times, perhaps with small changes. An efficient
More informationR: BASICS. Andrea Passarella. (plus some additions by Salvatore Ruggieri)
R: BASICS Andrea Passarella (plus some additions by Salvatore Ruggieri) BASIC CONCEPTS R is an interpreted scripting language Types of interactions Console based Input commands into the console Examine
More informationNumeric Vectors STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley
Numeric Vectors STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat/stat133 Course web: gastonsanchez.com/stat133 Data Types and Structures To make the
More informationBasic R Part 1 BTI Plant Bioinformatics Course
Basic R Part 1 BTI Plant Bioinformatics Course Spring 2013 Sol Genomics Network Boyce Thompson Institute for Plant Research by Jeremy D. Edwards What is R? Statistical programming language Derived from
More informationIntroduction to R Benedikt Brors Dept. Intelligent Bioinformatics Systems German Cancer Research Center
Introduction to R Benedikt Brors Dept. Intelligent Bioinformatics Systems German Cancer Research Center What is R? R is a statistical computing environment with graphics capabilites It is fully scriptable
More informationStatistics 120 Statistical Computing With R. First Prev Next Last Go Back Full Screen Close Quit
Statistics 120 Statistical Computing With R First Prev Next Last Go Back Full Screen Close Quit The R System This course uses the R computing environment for practical examples. R serves both as a statistical
More informationLecture 1: Getting Started and Data Basics
Lecture 1: Getting Started and Data Basics The first lecture is intended to provide you the basics for running R. Outline: 1. An Introductory R Session 2. R as a Calculator 3. Import, export and manipulate
More informationR package
R package www.r-project.org Download choose the R version for your OS install R for the first time Download R 3 run R MAGDA MIELCZAREK 2 help help( nameofthefunction )? nameofthefunction args(nameofthefunction)
More informationIntroduction to R: Using R for Statistics and Data Analysis. BaRC Hot Topics
Introduction to R: Using R for Statistics and Data Analysis BaRC Hot Topics http://barc.wi.mit.edu/hot_topics/ Why use R? Perform inferential statistics (e.g., use a statistical test to calculate a p-value)
More informationA Brief Introduction to R
A Brief Introduction to R Babak Shahbaba Department of Statistics, University of California, Irvine, USA Chapter 1 Introduction to R 1.1 Installing R To install R, follow these steps: 1. Go to http://www.r-project.org/.
More informationBjørn Helge Mevik Research Computing Services, USIT, UiO
23.11.2011 1 Introduction to R and Bioconductor: Computer Lab Bjørn Helge Mevik (b.h.mevik@usit.uio.no), Research Computing Services, USIT, UiO (based on original by Antonio Mora, biotek) Exercise 1. Fundamentals
More informationShort Introduction to R
Short Introduction to R Paulino Pérez 1 José Crossa 2 1 ColPos-México 2 CIMMyT-México June, 2015. CIMMYT, México-SAGPDB Short Introduction to R 1/51 Contents 1 Introduction 2 Simple objects 3 User defined
More informationPart 1: Getting Started
Part 1: Getting Started 140.776 Statistical Computing Ingo Ruczinski Thanks to Thomas Lumley and Robert Gentleman of the R-core group (http://www.r-project.org/) for providing some tex files that appear
More informationSTAT 540 Computing in Statistics
STAT 540 Computing in Statistics Introduces programming skills in two important statistical computer languages/packages. 30-40% R and 60-70% SAS Examples of Programming Skills: 1. Importing Data from External
More informationGetting Started. Slides R-Intro: R-Analytics: R-HPC:
Getting Started Download and install R + Rstudio http://www.r-project.org/ https://www.rstudio.com/products/rstudio/download2/ TACC ssh username@wrangler.tacc.utexas.edu % module load Rstats %R Slides
More informationStatistics for Biologists: Practicals
Statistics for Biologists: Practicals Peter Stoll University of Basel HS 2012 Peter Stoll (University of Basel) Statistics for Biologists: Practicals HS 2012 1 / 22 Outline Getting started Essentials of
More informationIN-CLASS EXERCISE: INTRODUCTION TO R
NAVAL POSTGRADUATE SCHOOL IN-CLASS EXERCISE: INTRODUCTION TO R Survey Research Methods Short Course Marine Corps Combat Development Command Quantico, Virginia May 2013 In-class Exercise: Introduction to
More informationData types and structures
An introduc+on to Data types and structures Noémie Becker & Benedikt Holtmann Winter Semester 16/17 Course outline Day 3 Review GeFng started with R Crea+ng Objects Data types in R Data structures in R
More informationEPIB Four Lecture Overview of R
EPIB-613 - Four Lecture Overview of R R is a package with enormous capacity for complex statistical analysis. We will see only a small proportion of what it can do. The R component of EPIB-613 is divided
More informationBasic R Part 1. Boyce Thompson Institute for Plant Research Tower Road Ithaca, New York U.S.A. by Aureliano Bombarely Gomez
Basic R Part 1 Boyce Thompson Institute for Plant Research Tower Road Ithaca, New York 14853-1801 U.S.A. by Aureliano Bombarely Gomez A Brief Introduction to R: 1. What is R? 2. Software and documentation.
More informationIntroduction to RStudio
Introduction to RStudio Ulrich Halekoh Epidemiology and Biostatistics, SDU May 4, 2018 R R is a language that started by Ross Ihaka and Robert Gentleman in 1991 as an open source alternative to S emphasizes
More informationBGGN 213 Working with R packages Barry Grant
BGGN 213 Working with R packages Barry Grant http://thegrantlab.org/bggn213 Recap From Last Time: Why it is important to visualize data during exploratory data analysis. Discussed data visualization best
More informationIntroduction to R: Part I
Introduction to R: Part I Jeffrey C. Miecznikowski March 26, 2015 R impact R is the 13th most popular language by IEEE Spectrum (2014) Google uses R for ROI calculations Ford uses R to improve vehicle
More informationR Basics / Course Business
R Basics / Course Business We ll be using a sample dataset in class today: CourseWeb: Course Documents " Sample Data " Week 2 Can download to your computer before class CourseWeb survey on research/stats
More informationInstruction: Download and Install R and RStudio
1 Instruction: Download and Install R and RStudio We will use a free statistical package R, and a free version of RStudio. Please refer to the following two steps to download both R and RStudio on your
More informationR basics workshop Sohee Kang
R basics workshop Sohee Kang Math and Stats Learning Centre Department of Computer and Mathematical Sciences Objective To teach the basic knowledge necessary to use R independently, thus helping participants
More informationSTAT 571A Advanced Statistical Regression Analysis. Introduction to R NOTES
STAT 571A Advanced Statistical Regression Analysis Introduction to R NOTES 2015 University of Arizona Statistics GIDP. All rights reserved, except where previous rights exist. No part of this material
More informationfile:///users/williams03/a/workshops/2015.march/final/intro_to_r.html
Intro to R R is a functional programming language, which means that most of what one does is apply functions to objects. We will begin with a brief introduction to R objects and how functions work, and
More informationRegression III: Advanced Methods
Lecture 2: Software Introduction Regression III: Advanced Methods William G. Jacoby Department of Political Science Michigan State University jacoby@msu.edu Getting Started with R What is R? A tiny R session
More informationLAB #1: DESCRIPTIVE STATISTICS WITH R
NAVAL POSTGRADUATE SCHOOL LAB #1: DESCRIPTIVE STATISTICS WITH R Statistics (OA3102) Lab #1: Descriptive Statistics with R Goal: Introduce students to various R commands for descriptive statistics. Lab
More informationComputational statistics Jamie Griffin. Semester B 2018 Lecture 1
Computational statistics Jamie Griffin Semester B 2018 Lecture 1 Course overview This course is not: Statistical computing Programming This course is: Computational statistics Statistical methods that
More informationAn introduction to R 1 / 29
An introduction to R 1 / 29 What is R? R is an integrated suite of software facilities for data manipulation, calculation and graphical display. Among other things it has: an effective data handling and
More informationsocial data science Introduction to R Sebastian Barfort August 07, 2016 University of Copenhagen Department of Economics 1/40
social data science Introduction to R Sebastian Barfort August 07, 2016 University of Copenhagen Department of Economics 1/40 welcome Course Description The objective of this course is to learn how to
More informationStatistical Software Camp: Introduction to R
Statistical Software Camp: Introduction to R Day 1 August 24, 2009 1 Introduction 1.1 Why Use R? ˆ Widely-used (ever-increasingly so in political science) ˆ Free ˆ Power and flexibility ˆ Graphical capabilities
More informationChapter 1 Introduction to using R with Mind on Statistics
Chapter 1 Introduction to using R with Mind on Statistics Manual overview The purpose of this manual is to help you learn how to use the free R software to perform the graphs, simulations, and data analyses
More informationRecap From Last Time: Today s Learning Goals BIMM 143. Data analysis with R Lecture 4. Barry Grant.
BIMM 143 Data analysis with R Lecture 4 Barry Grant http://thegrantlab.org/bimm143 Recap From Last Time: Substitution matrices: Where our alignment match and mis-match scores typically come from Comparing
More informationIntroduction to Statistics using R/Rstudio
Introduction to Statistics using R/Rstudio R and Rstudio Getting Started Assume that R for Windows and Macs already installed on your laptop. (Instructions for installations sent) R on Windows R on MACs
More informationLab 1: Getting started with R and RStudio Questions? or
Lab 1: Getting started with R and RStudio Questions? david.montwe@ualberta.ca or isaacren@ualberta.ca 1. Installing R and RStudio To install R, go to https://cran.r-project.org/ and click on the Download
More informationRNA-Seq. Joshua Ainsley, PhD Postdoctoral Researcher Lab of Leon Reijmers Neuroscience Department Tufts University
RNA-Seq Joshua Ainsley, PhD Postdoctoral Researcher Lab of Leon Reijmers Neuroscience Department Tufts University joshua.ainsley@tufts.edu Day four Quantifying expression Intro to R Differential expression
More information8.1 Come analizzare i dati: R
8.1 Come analizzare i dati: R Insegnamento di Informatica Elisabetta Ronchieri Corso di Laurea di Economia, Universitá di Ferrara I semestre, anno 2014-2015 Elisabetta Ronchieri (Universitá) Insegnamento
More informationBGGN 213 More on R functions and packages Barry Grant
BGGN 213 More on R functions and packages Barry Grant http://thegrantlab.org/bggn213 Recap From Last Time: Data frames are created with the data.frame() function as well as the read.table() family of functions
More informationGETTING STARTED. A Step-by-Step Guide to Using MarketSight
GETTING STARTED A Step-by-Step Guide to Using MarketSight Analyze any dataset Run crosstabs Test statistical significance Create charts and dashboards Share results online Introduction MarketSight is a
More informationStat 302 Statistical Software and Its Applications Introduction to R
Stat 302 Statistical Software and Its Applications Introduction to R Yen-Chi Chen Department of Statistics, University of Washington Autumn 2016 1 / 23 Statistical Software There are many, many statistical
More informationR version has been released on (Linux source code versions)
Installation of R and Bioconductor R is a free software environment for statistical computing and graphics. It is based on the statistical computer language S. It is famous for its wide set of statistical
More informationGetting Started in R
Getting Started in R Giles Hooker May 28, 2007 1 Overview R is a free alternative to Splus: a nice environment for data analysis and graphical exploration. It uses the objectoriented paradigm to implement
More informationBasics of R. > x=2 (or x<-2) > y=x+3 (or y<-x+3)
Basics of R 1. Arithmetic Operators > 2+2 > sqrt(2) # (2) >2^2 > sin(pi) # sin(π) >(1-2)*3 > exp(1) # e 1 >1-2*3 > log(10) # This is a short form of the full command, log(10, base=e). (Note) For log 10
More informationIntroduction to R (BaRC Hot Topics)
Introduction to R (BaRC Hot Topics) George Bell September 30, 2011 This document accompanies the slides from BaRC s Introduction to R and shows the use of some simple commands. See the accompanying slides
More informationBIO5312: R Session 1 An Introduction to R and Descriptive Statistics
BIO5312: R Session 1 An Introduction to R and Descriptive Statistics Yujin Chung August 30th, 2016 Fall, 2016 Yujin Chung R Session 1 Fall, 2016 1/24 Introduction to R R software R is both open source
More informationSTA 248 S: Some R Basics
STA 248 S: Some R Basics The real basics The R prompt > > # A comment in R. Data To make the variable x equal to 2 use > x x = 2 To make x a vector, use the function c() ( c for concatenate)
More informationAn Introduction to Statistical Computing in R
An Introduction to Statistical Computing in R K2I Data Science Boot Camp - Day 1 AM Session May 15, 2017 Statistical Computing in R May 15, 2017 1 / 55 AM Session Outline Intro to R Basics Plotting In
More informationIntroduction to R. base -> R win32.exe (this will change depending on the latest version)
Dr Raffaella Calabrese, Essex Business School 1. GETTING STARTED Introduction to R R is a powerful environment for statistical computing which runs on several platforms. R is available free of charge.
More informationAn Introductory Tutorial: Learning R for Quantitative Thinking in the Life Sciences. Scott C Merrill. September 5 th, 2012
An Introductory Tutorial: Learning R for Quantitative Thinking in the Life Sciences Scott C Merrill September 5 th, 2012 Chapter 2 Additional help tools Last week you asked about getting help on packages.
More informationInstalling and running R
Installing and running R The R website: http://www.r-project.org/ R on the web here you can find information on the software, download the current version R-2.9.2 (released on 2009-08-24), packages, tutorials
More informationData Classes. Introduction to R for Public Health Researchers
Data Classes Introduction to R for Public Health Researchers Data Types: One dimensional types ( vectors ): - Character: strings or individual characters, quoted - Numeric: any real number(s) - Integer:
More informationR (and S, and S-Plus, another program based on S) is an interactive, interpretive, function language.
R R (and S, and S-Plus, another program based on S) is an interactive, interpretive, function language. Available on Linux, Unix, Mac, and MS Windows systems. Documentation exists in several volumes, and
More informationIST Computational Tools for Statistics I. DEÜ, Department of Statistics
IST 1051 Computational Tools for Statistics I 1 DEÜ, Department of Statistics Course Objectives Computational Tools for Statistics-I course can increase the understanding of statistics and helps to learn
More informationWhat is Matlab? The command line Variables Operators Functions
What is Matlab? The command line Variables Operators Functions Vectors Matrices Control Structures Programming in Matlab Graphics and Plotting A numerical computing environment Simple and effective programming
More informationBusiness Statistics: R tutorials
Business Statistics: R tutorials Jingyu He September 29, 2017 Install R and RStudio R is a free software environment for statistical computing and graphics. Download free R and RStudio for Windows/Mac:
More informationIntroduction to R and Bioconductor
Introduction to R and Bioconductor RNA-Seq / ChIP-Seq Data Analysis Workshop 10 September 2012 CSC, Helsinki Nicolas Delhomme A bit of interaction? What is your R knowledge, on a 0 (beginner) to 2 (expert)
More informationThis document is designed to get you started with using R
An Introduction to R This document is designed to get you started with using R We will learn about what R is and its advantages over other statistics packages the basics of R plotting data and graphs What
More informationRecap From Last Time:
BIMM 143 More on R functions and packages Lecture 7 Barry Grant http://thegrantlab.org/bimm143 Office hour check-in! Recap From Last Time: Covered data input with the read.table() family of functions including
More informationA brief introduction to R
A brief introduction to R Cavan Reilly September 29, 2017 Table of contents Background R objects Operations on objects Factors Input and Output Figures Missing Data Random Numbers Control structures Background
More informationLECTURE NOTES FOR ECO231 COMPUTER APPLICATIONS I. Part Two. Introduction to R Programming. RStudio. November Written by. N.
LECTURE NOTES FOR ECO231 COMPUTER APPLICATIONS I Part Two Introduction to R Programming RStudio November 2016 Written by N.Nilgün Çokça Introduction to R Programming 5 Installing R & RStudio 5 The R Studio
More informationModule 1: Introduction RStudio
Module 1: Introduction RStudio Contents Page(s) Installing R and RStudio Software for Social Network Analysis 1-2 Introduction to R Language/ Syntax 3 Welcome to RStudio 4-14 A. The 4 Panes 5 B. Calculator
More informationProgramming R. Manuel J. A. Eugster. Chapter 1: Basic Vocabulary. Last modification on April 11, 2012
Manuel J. A. Eugster Programming R Chapter 1: Basic Vocabulary Last modification on April 11, 2012 Draft of the R programming book I always wanted to read http://mjaeugster.github.com/progr Licensed under
More informationR Primer for Introduction to Mathematical Statistics 8th Edition Joseph W. McKean
R Primer for Introduction to Mathematical Statistics 8th Edition Joseph W. McKean Copyright 2017 by Joseph W. McKean at Western Michigan University. All rights reserved. Reproduction or translation of
More informationInput/Output Data Frames
Input/Output Data Frames Statistics 135 Autumn 2005 Copyright c 2005 by Mark E. Irwin Input/Output Importing text files Rectangular (n rows, c columns) Usually you want to use read.table read.table(file,
More informationWeekly Discussion Sections & Readings
Weekly Discussion Sections & Readings Teaching Fellows (TA) Name Office Email Mengting Gu Bass 437 mengting.gu (at) yale.edu Paul Muir Bass437 Paul.muir (at) yale.edu Please E-mail cbb752@gersteinlab.org
More informationWhy use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D)
MATLAB(motivation) Why use MATLAB? Mathematcal computations Used a lot for problem solving Statistical Analysis (e.g., mean, min) Visualisation (1D-3D) Signal processing (Fourier transform, etc.) Image
More informationAdvanced R Programming - Lecture 1
Advanced R Programming - Lecture 1 Krzysztof Bartoszek (slides by Leif Jonsson and Måns Magnusson) Linköping University krzysztof.bartoszek@liu.se 29 August 2017 1/ 43 Today 1 Aim of the course 2 3 4 5
More informationIntroduction to R 21/11/2016
Introduction to R 21/11/2016 C3BI Vincent Guillemot & Anne Biton R: presentation and installation Where? https://cran.r-project.org/ How to install and use it? Follow the steps: you don t need advanced
More informationIntroduction to 3/15/2012. Poll Are You Sticking Around for Part 2? 1. Yes 2. No. Steve Berman, FCAS, MAAA Jim Guszcza, FCAS, MAAA
Introduction to CAS RPM Seminar March 19, 2012 Steve Berman, FCAS, MAAA Jim Guszcza, FCAS, MAAA Poll Are You Sticking Around for Part 2? 1. Yes 2. No 1 1 Poll How Much Do You Know About R? 1. Isn t that
More informationR for large data and bioinformatics
R for large data and bioinformatics Thomas Lumley Ken Rice Universities of Washington and Auckland Auckland, November 2013 Introduction: Course Aims Under the hood of R R essentials, and programming skills
More informationGS Analysis of Microarray Data
GS01 0163 Analysis of Microarray Data Keith Baggerly and Kevin Coombes Section of Bioinformatics Department of Biostatistics and Applied Mathematics UT M. D. Anderson Cancer Center kabagg@mdanderson.org
More informationIntro Intro.3
Intro.1 Intro.2 Introduction to R Much of the content here is from Appendix A of my Analysis of Categorical Data with R book (www.chrisbilder.com/ categorical). All R code is available in AppendixInitialExamples.R
More informationIntroduction to R/Bioconductor
Introduction to R/Bioconductor MCBIOS-2015 Workshop Thomas Girke March 12, 2015 Introduction to R/Bioconductor Slide 1/62 Introduction Look and Feel of the R Environment R Library Depositories Installation
More informationSISG/SISMID Module 3
SISG/SISMID Module 3 Introduction to R Ken Rice Tim Thornton University of Washington Seattle, July 2018 Introduction: Course Aims This is a first course in R. We aim to cover; Reading in, summarizing
More informationIntroduction to R. Stat Statistical Computing - Summer Dr. Junvie Pailden. July 5, Southern Illinois University Edwardsville
Introduction to R Stat 575 - Statistical Computing - Summer 2016 Dr. Junvie Pailden Southern Illinois University Edwardsville July 5, 2016 Why R R offers a powerful and appealing interactive environment
More information