L3_R - ECEN 689 Statistical Computation in GSP

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
ECEN 689 Statistical Computation in GSP http://www.ece.tamu.edu/~ulisses/ECEN689/ Lecture 3: Introduction to R and Bioconductor Ulisses Braga-Neto Genomic Signal Processing Laboratory Department of Electrical and Computer Engineering Texas A&M University
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The R Statistical Software "R is a statistical computer program, made available through the Internet under the General Public License (GPL), for Microsoft Windows 95 or later, for a variety of Unix and Linux platforms, and for the Apple Macintosh (OS versions newer than 8.6). R provides an environment in which you can perform statistical analysis and produce graphics." (P. Dalgaard, Introductory Statistics with R)
Background image of page 2
Brief History R evolved from the quite popular S-plus commercial statistical software. The first version of R was created by Ross Ihaka and Robert Gentleman from the University of Auckland, New Zealand, as a "reduced S" for teaching. They named it "R" because it was the letter before "S" (or was it their initials?) In any case, R was soon after released under the GPL and benefited from the explosion of open-source software in the mid-1990's. It has a large community of users who exchange ideas on open forums and contribute their own code in the form of R packages .
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
R Installation • Go to: http://www.r-project.org • Click on "download R" • Select one of the U.S. CRAN mirrors, e.g.: http://cran.stat.ucla.edu • Click on "Windows" then "base" then "Download R 2.9.2 for Windows" • Save file to "Documents" folder, click and follow instructions (accept defaults).
Background image of page 4
Interactive Console • A typical R session consists of typed-in commands, line by line, and responses from the system after each line: > 2+2 [1] 4 > x <- exp(1) > x [1] 2.718282
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Vectors • R is an objected-oriented language. Every variable in R is an object. • The most used objects are numeric vectors . > weight <- c(60, 72, 57, 90, 95, 72) > weight [1] 60 72 57 90 95 72
Background image of page 6
Other kinds of Vectors Character vectors > patient.names <- c("John", "Paul", "Mary", "Tom", "Alice", "Nancy") > names(weight) <- patient.names > weight John Paul Mary Tom Alice Nancy 60 72 57 90 95 72 Logical vectors > weight>70 John Paul Mary Tom Alice Nancy FALSE TRUE FALSE TRUE TRUE TRUE
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Vectorized Arithmetic • When arithmetic operations are applied to vectors, they are performed element by element, producing another vector. > height <- c(1.75, 1.80, 1.65, 1.90, 1.74, 1.91) > bmi <- weight/height^2 > bmi John Paul Mary Tom Alice Nancy 19.591 22.222 20.936 24.930 31.377 19.736
Background image of page 8
Subsetting • Subsetting a vector is done with "[ ]" > weight[1] John 60 > weight[c(1,2,3)] John Paul Mary 60 72 57 > weight[2:5] Paul Mary Tom Alice 72 57 90 95 > weight[-1] ?
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Conditional Selection • One can subset using relational operators
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 39

L3_R - ECEN 689 Statistical Computation in GSP

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online