R-Graphics Day 2 Stephen Opiyo. Basic Graphs One of the main reasons data analysts turn to R is for its strong graphic capabilities. R generates publication-ready.

Slides:



Advertisements
Similar presentations
1 Statistics 202: Statistical Aspects of Data Mining Professor David Mease Tuesday, Thursday 9:00-10:15 AM Terman 156 Lecture 5 = More of chapter 3 Agenda:
Advertisements

R for Macroecology Functions and plotting. A few words on for  for( i in 1:10 )
R Language. What is R? Variables in R Summary of data Box plot Histogram Using Help in R.
EViews Student Version. Today’s Workshop Basic grasp of how EViews manages data Creating Workfiles Importing data Running regressions Performing basic.
Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Introduction to R Graphics
Graphics in R data analysis and visualization Katia Oleinik Scientific Computing and Visualization Boston University
Exemples instructifs… Représentations graphiques.
R tutorial g/methods2.2010/R-intro.pdf.
R graphics  R has several graphics packages  The plotting functions are quick and easy to use  We will cover:  Bar charts – frequency, proportion 
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 4.
Customizing Graphs Base graphics options. plot() The workhorse plotting function plot(x) plots values of x in sequence or a barplot plot(x, y) produces.
DATA VISUALIZATION UNIVARIATE (no review- self study) STEM & LEAF BOXPLOT BIVARIATE SCATTERPLOT (review correlation) Overlays; jittering Regression line.
Evan Girvetz Winkenwerder Introduction to Graphics in R © R Foundation, from
FISH 397C Winter 2009 Evan Girvetz More Complex Graphics in R © R Foundation, from
Baburao Kamble (Ph.D) University of Nebraska-Lincoln Data Analysis Using R Week5: Charts/Plots in R.
An Introduction to R graphics Elizabeth Garrett-Mayer Slides borrowed from Cody Chiuzan & Delia Voronca March 24, 2014.
AN INTRODUCTION TO GRAPHICS IN R. Today Overview Overview –Gallery of R Graph examples High-Level Plotting Functions High-Level Plotting Functions Low-Level.
Graphics in R. X
Baburao Kamble (Ph.D) University of Nebraska-Lincoln
Creating Graphs in R Graphing techniques Sharon style! (I am not sure if this is a good or bad thing but this is what I do...)
„  1999 BG Mobasseri1 9/18/2015 June 2 GRAPHICS IN MATLAB- PART I BASIC PLOTTING.
Sendplot Lori Shepherd April 06, sendplot The Problem: The Approach: How can we quickly generate useful data and get it back to scientists/collaborators.
Graphing Parameters Titles X-Axis Title Y-Axis Title Legend Scales Color Gridlines library(help="graphics") Basic Chart Types The R Graphics Package LineHistogram.
A Brief Introduction to R Programming Darren J. Fitzpatrick, PhD The Bioinformatics Support Team 27/08/2015.
An Introduction to R graphics Cody Chiuzan Division of Biostatistics and Epidemiology Computing for Research I, 2012.
I❤RI❤R Kin Wong (Sam) Game Plan Intro R Import SPSS file Descriptive Statistics Inferential Statistics GraphsQ&A.
Chapter 2 Analysis using R. Few Tips for R Commands included here CANNOT ALWAYS be copied and pasted directly without alteration. –One major reason is.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Learn R Toolkit D Kelly O'DayBox, Dot, Histogram, Strip Charts Mod 5 –Box Charts: 1 Module 5 Box, Dot, Histogram, Strip Charts Do See & HearRead Learn.
R-Graphics Stephen Opiyo. Basic Graphs One of the main reasons data analysts turn to R is for its strong graphic capabilities. R generates publication-ready.
An Introduction to R Statistical Computing AMS 597 Stony Brook University Spring 2009 By Tianyi Zhang.
Introduction to R Introductions What is R? RStudio Layout Summary Statistics Your First R Graph 17 September 2014 Sherubtse Training.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
Scientific Computing (w1) R Computing Workshops An Introduction to Scientific Computing workshop 1.
Plotting Complex Figures Using R
Mr. Magdi Morsi Statistician Department of Research and Studies, MOH
Data Science and Big Data Analytics Chap 3: Data Analytics Using R
Machine Learning (ML) with Weka Weka can classify data or approximate functions: choice of many algorithms.
Introduction to CADStat. CADStat and R R is a powerful and free statistical package [
Data & Graphing vectors data frames importing data contingency tables barplots 18 September 2014 Sherubtse Training.
S-PLUS Lecture 6 Jaeyong Lee. Graphical Parameters type = “c”: c =p (default), l, b,s,o,h,n. pch=“+” : character or numbers 1 – 18 lty=1 : numbers lwd=2.
1 Statistics & R, TiP, 2011/12 Multivariate Methods  Multivariate data  Data display  Principal component analysis Unsupervised learning technique 
More points Multiple figures par(mfcol=c(3,2) par (mfrow)=c(3,2)
Decision Tree Lab. Load in iris data: Display iris data as a sanity.
Introduction to plotting data Fish 552: Lecture 4.
Review > head(tripData) > table(speciesData$SpeciesCode) > grep("a", c("aa","ab","bb")) > c(2,3,8) %in% c(1,2,3,5,7,9) > bocTrip
EGR 106 – Week 5 – 2-D Plots Question : Why do engineers use plots? Answer : To analyze, visualize, and present data. Matlab has many useful plotting options.
Review > mean(humidity, na.rm=T) > humidity[!is.na(humidity)] > X x Y Y[[1]][2,3] > zone.fac
16BIT IITR Data Collection Module If you have not already done so, download and install R from download.
Statistical Programming Using the R Language Lecture 2 Basic Concepts II Darren J. Fitzpatrick, Ph.D April 2016.
EMPA Statistical Analysis
R workshop for Advanced users
Using R Graphs in R.
Statistical Programming Using the R Language
Lecture 25: Exploring data
Summary Statistics in R Commander
Journal of Vision. 2013;13(7):20. doi: / Figure Legend:
Trevor A. Branch FISH 552 Introduction to R
R Assignment #4: Making Plots with R (Due – by ) BIOL
I/O: Input and Output.
Data Analysis Module: Basic Visualizations
Univariate Data Exploration
K-Means Lab.
Recoding II: Numerical & Graphical Descriptives
Plotting Signals in MATLAB
Stat 251 (2009, Summer) Lab 2 TA: Yu, Chi Wai.
R Course 5th lecture.
R Course 5th lecture.
R for Statistics and Graphics
Presentation transcript:

R-Graphics Day 2 Stephen Opiyo

Basic Graphs One of the main reasons data analysts turn to R is for its strong graphic capabilities. R generates publication-ready figures. "graphics" library loads by default when R is started. Ready to go as soon as R opens. 2

Graphing basics Plotting commands 1.High-level functions: Create a new plot on the graphics device 2.Low-level functions: Add more information to an already existing plot, such as extra points, lines, and labels 3

Common high-level functions plot(): A generic function that produces a type of plot that is dependent on the type of the first argument. hist(): Creates a histogram of frequencies barplot(): Creates a histogram of values boxplot(): Creates a boxplot 4

Example 1 High-level functions Download data D2_Data_1 - metabolomics data with 10 peaks identified by Liquid Chromatography-Mass Spectrometer Open file D2_Example_1.R R has datasets with packages, e.g., mtcars - Will find out about the data from r using ?mtcars 5

plot type description: type= " " p= points l =lines o= over plotted points and lines b, c= points (empty if "c") joined by lines s= stair steps h= histogram-like vertical lines n = does not produce any points or lines Lower level graphical functions 6

pch (plotting characters)=“ ” : character or numbers col (color) = “ ” : character or numbers lty (line type) = numbers lwd (line width) = numbers xlab (x label) =“string”, ylab (y label) =“string” main (heading) =“string” xlim (x limit) = c(lo,hi), ylim (y limit) = c(lo,hi) cex controls the symbol size in the plot, default is cex=1, 7

Lower-level graphing functions pch=0,square pch=1,circle pch=2,triangle point up pch=3,plus pch=4,cross pch=5,diamond pch=6,triangle point down pch=7,square cross pch=8,star pch=9,diamond plus pch=10,circle plus pch=11,triangles up and down pch=12,square plus pch=13,circle cross pch=14,square and triangle down pch=15, filled square blue pch=16, filled circle blue pch=17, filled triangle point up blue pch=18, filled diamond blue pch=19,solid circle blue pch=20,bullet (smaller circle) pch=21, filled circle red pch=22, filled square red pch=23, filled diamond red pch=24, filled triangle point up red pch=25, triangle point down red 8

Lower-level graphing functions Symbol shapes and colors 9

Lower-level graphing functions Adding text text() text(x, y, “text”, options) points() add some more points to the graph points(x, y, options) Saving graphs in Rstudio 10

Example 2 Download data D2_Data_2 - metabolomics data with 4 peaks identified by Liquid Chromatography-Mass Spectrometer Open file D2_Example_2.R 11

3-dimensional Scatterplots Need a package scatterplot3d Install package scatterplot3d using install.packages("scatterplot3d") command Alternatively install using Rstudio using Packages 12

Multiple graph on one page Combining multiple plots using par () and mfrow = c(nrows, ncols) to create a matrix of nrows by ncols ?par par(mfrow=c(1,2)) 13

Exercise 1 14 par(mfrow=c(3,5)) plot(D2_Data_2[,2], D2_Data_2[,3], type="p", pch=1, col="1", xlab ="Peak1", ylab ="Peak2", main="Plot of Peak1 vs Peak2", font.main =1) Replace pch=1 and col =1 with 2 to 15: Export the graph and save it as Day_2_Graph.pdf

Basic statistics using R Open file D2_Example_3.R - metabolomics data with 4 peaks identified by Liquid Chromatography-Mass Spectrometer Mean, standard deviation, median, mode Correlation Ttest 15

1) Use R dataset called iris 2) What is the mean and standard deviation of Sepal.Length? 3) Find the correlation between Sepal.Length and Sepal.Width 4) Perform independent ttest between Petal.Length and Petal.Width 5) Test weather the mean of Sepal.Length is equal to 4 6) Find the median of Petal.Length 16 Exercise 2