Upcoming SlideShare
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Standard text messaging rates apply

# Itmat pcbi-r-course-1

464

Published on

First part of 3-part course on teaching the R statistical package.

First part of 3-part course on teaching the R statistical package.

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
464
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
0
0
Likes
0
Embeds 0
No embeds

No notes for slide
• Exercise 1: Use the sequence function to 1:20 by 2Exercise 2: Use rep() to create a vector with a sequence of number from 1 to 3, repeated three timesExercise 3: Create a vector 1:10 with 3 consecutive repeating values (e.g. 1 1 1 2 2 2 … 10 10 10 )
• Changing the data type of a single element changes the type of the rest of the elements.The one exception to this is “missing values” represented by the special constant “NA”. See example above
• ### Transcript

• 1. Intro to using R for Bioinformatics: Part 1 : The Basics
Angel Pizarro
angel@upenn.edu
• 2. Injecting a bit of reality
• 3. Taking it a bit further…
Waxing floors is not fun, and may not seem relevant, but have some faith Daniel-san
• 4. Outline
We will teach you some basic uses of R
“Do & Tell” method where you will be asked to do an exercise and once done, we will explain what just happened.
Will cover basics, plotting and microarray analysis
We will not teach you statistics.
• 5. What is ?
R is a language and environment for statistical computing and graphics.
– http://www.r-project.org
You can do stuff like this
• 6. Install & Run R
Start R
On Windows, use Tinn-R
On Mac, use the source R application
On Linux, use the console
• 7. Help is plentiful
Help in three ways
Too much! Get me out!
• 8. More Help
help.start()
Start an HTML help session
help(mean)
Looks up the mean() function's help page
?mean
help.search(mean)
Displays all help pages that contain text “mean”
??mean
• 10. The Basics
• 11.
• 12.
• 13.
• 14. Basic Algebra
You will also see this form:
• 15. Variables
“x” and “y” are variables.
They are pointers to some value
They can also be pointers to some function
• 16. Vectors
Results
• 17. Small tangent: What is “c (1,2,3)”?
Use the help()
• 18. Accessing Vector Members
In R, Vectors start indexes at 1. Most programming languages start indexing at zero
Also, NOT WHAT YOU THINK IT IS! It is a INDEX VECTOR, meaning that you access the members of a vector with a vector
• 19. Small Tangent 2: Creating Sequences
Create regular sequences using a colon
Colon has high operator precedence
Also see the seq() function
• 20. Vectors
Are a list of items of the same data type
Short for “double precision floating point number”
• 21. Doing Stuff with Vectors
Math operations occur on each element in sequence
Returns a vector of the same size
• 22. Factors
Simply a vector of items that mean something
Disease classifications, drug dosage, US states, months, hapmap ethnic group
Can be ordered
Can have multiple levels
GO Functions
• 23. Array and Matrix
Multi-dimensional generalizations of vectors
k-dimensions where k > 0
Assigned by the dim attribute
Can be indexed by two or more indices
If a single index value (can be a vector) is given, then dim is ignored and underlying vector values are accessed directly
Unless the given index values is also an array
Matrix is a two-dimensional array
• 24. Example
An INDEX ARRAY
• 25. List
An ordered collection of named components
• 26. List Access
• 27. Data Frame
Bastard step child of List and Matrix
Essentially a list of vectors of same length
Closest representation to an Excel file in R
Easiest way to make one is to read in a CSV file
• 28.
• 29.
• 30. Functions