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.

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.
Plotting Selim Aksoy Bilkent University Department of Computer Engineering
Lecture (4) Plotting & Programming (1) Eng. Osama Talaat 1.
Introduction to R Graphics
Graphics in R data analysis and visualization Katia Oleinik Scientific Computing and Visualization Boston University
Exemples instructifs… Représentations graphiques.
5/2/ Lecture 41 STATS 330: Lecture 4. 5/2/ Lecture 42 Housekeeping My contact details…. Plus much else on course web page
R graphics  R has several graphics packages  The plotting functions are quick and easy to use  We will cover:  Bar charts – frequency, proportion 
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
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.
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
Lecture 9 Plotting in 2-D Plotting in 2-D, Plotting Multiple Curves, Plotting with Figures, Plot Settings, Scaling, Legends © 2007 Daniel Valentine. All.
Python plotting for lab folk Only the stuff you need to know to make publishable figures of your data. For all else: ask Sourish.
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.
Fundamental Graphics in R Prof. Ke-Sheng Cheng Dept. of Bioenvironmental Systems Eng. National Taiwan University.
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
R Graphics Lori Shepherd-Kirchgraber May 22, 2012.
PLOTS AND FIGURES DAVID COOPER SUMMER Plots One of the primary uses for MATLAB is to be able to create publication quality figures from you data.
ENG College of Engineering Engineering Education Innovation Center 1 2D Plots 1 in MATLAB Topics Covered: 1.Plotting basic 2-D plots The plot()
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.
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.
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.
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Adding Graphical Elements Essentials for.
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.
Learning R hands on. Organization of Folders: Class Data folder has datasets (end in.csv or.rda) Rcode has the scripts of R commands that can cut and.
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.
Recap Chapter 5 “Plotting” Two Dimensional Plots Simple x-y Plots Titles, Labels and Grids Multiple Plots.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
R (3) Introduction to Graphics. The main guide R in Action Data Analysis and Graphics with R Robert I. Kabacoff
Scientific Computing (w1) R Computing Workshops An Introduction to Scientific Computing workshop 1.
Plotting Complex Figures Using R
Data Science and Big Data Analytics Chap 3: Data Analytics Using R
Introduction to Graphics in R 3/12/2014. First, let’s get some data Load the Duncan dataset It’s in the car package. Remember how to get it? – library(car)
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.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Lab 2 : potting to Matlab Networks.
Introduction to plotting data Fish 552: Lecture 4.
Statistical analysis - R Language Shiny Server. R 的 Web App - Shiny RStudio 開發的一個 R package web application 的架構 可直接在網頁上互動操作 R 的程式 source :
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
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Statistical Programming Using the R Language Lecture 2 Basic Concepts II Darren J. Fitzpatrick, Ph.D April 2016.
Creating a Plot The plot function can take one or more inputs; e.g. plot (x, y) or plot (y) Note that in the two-argument version, the vectors x and.
Using R Graphs in R.
Statistical Programming Using the R Language
Lecture 25: Exploring data
Summary Statistics in R Commander
Trevor A. Branch FISH 552 Introduction to R
R Assignment #4: Making Plots with R (Due – by ) BIOL
Data Analysis Module: Basic Visualizations
Net 222: Communications and networks fundamentals (Practical Part)
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.
Presentation transcript:

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 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 Download data D2_Data_1 Open file D2_Example_1.R R dataset mtcars 5

Lower level graphical functions pch (plotting characters)=“ ” : character or numbers col (color) = “ ” : character or numbers lty = numbers lwd = numbers axes = “L”: L= F, T xlab =“string”, ylab=“string” sub = “string”, main =“string” xlim = c(lo,hi), ylim= c(lo,hi) cex controls the symbol size in the plot, default is cex=1, 6

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 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 Open file D2_Example_2.R 11

Making a histogram Make histograms with varying the number of bars (also called ‘bins’ or ‘cells’), e.g. simdata <-rchisq(100,8) hist(simdata) # default number of bins Setting your own breakpoints bps <- c(0,2,4,6,8,10,15,25) hist(simdata,breaks=bps) 12

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

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)) 14

Exercise 15 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