Statistical Programming with R

Size: px
Start display at page:

Download "Statistical Programming with R"

Transcription

1 Statistical Programming with R Lecture 9: Basic graphics in R Part 2 Bisher M. Iqelan biqelan@iugaza.edu.ps Department of Mathematics, Faculty of Science, The Islamic University of Gaza , Semester 1

2 barplot() function The barplot() command creates bar charts. The bars can be drawn as vertical or horizontal. Example: ## Make values for basic barplot > rain = c(34, 32, 23, 15, 10, 8, 6, 9, 12, 21, 24, 29) > month = month.abb[1:12] # Make labels ## Now draw the plot ## Increase y-axis limits and add titles > barplot(rain, ylim = c(0, 35), names = month, main = "Rainfall", xlab = "Month", ylab = "Rainfall in mm") # las=3 is an option to make the labels perpindicular # > grid(ny = 35, nx = 0) to make horizontal lines (net) Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

3 barplot() Graph Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

4 Example 2: Horizontal bar charts ## More data, this time as a matrix > data(vadeaths) # Data are in R datasets ## Now draw stacked bar chart with horizontal bars ## Note that xlab annotates bottom axis ## There is no legend automatically > barplot(vadeaths, xlab = "Deaths per 1000", horiz = TRUE) ## Add main title afterwards > title(main = "Death Rates in Virginia (1940)") Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

5 Horizontal bar charts graph Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

6 A bar chart with adjacent (grouped) bars and a legend Example: ## Same data as previous - a Matrix > data(vadeaths) # Data are in R datasets ## Draw bar chart with adjacent bars ## Add a legend. Note parameters passed to legend command > barplot(vadeaths, beside = TRUE, legend = TRUE, args.legend = list(bty = "n", title = "Age category")) ## Add titles afterwards > title(ylab = "Deaths per 1000", xlab = "Category") Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

7 A bar chart with adjacent (grouped) bars and a legend Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

8 Legend A legend can be added via the legend() function. It can produce a legend on a plot, displaying points or lines with accompanying text. The function accepts x= and y= arguments to specify the coordinates where the legend should be placed. Otherwise, you can specify x and y coordinates using a text string. The text options are bottomright, bottom, bottomleft, left, topleft, top, topright, right, and center. A legend= argument with the text to appear in the legend. Usually this will be a character or expression vector. Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

9 Examples: A Legend To A Plot More Options ## Make an empty plot to create a coordinate system plot(0:10, 0:10, type = "n") ## Add some points/lines points(3:5,4:6,type="b",lwd=2,lty=1,pch=21,col="black") points(2:4,2:4,type="b",lwd=2,lty=2,pch=24,col="blue") points(5:7,5:7,type="b",lwd=2,lty=3,pch=25,col="red") ## Make a list of names as labels for each set ## of lines/points mydata = c("line1", "Line2", "Line3") ## Add a legend, take care to match up line/point ## parameters legend("topright", legend = mydata, lty = 1:3, lwd = 2, col = c("black", "red", "blue"), pch = c(21, 24, 25)) Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

10 A Legend To A Plot More Options: Graph Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

11 Examples: Continue... ## It is often easier to make named objects for colors ## and plot characters plcols = c("black", "red", "blue") plchr = c(21, 24, 25) ## Add more legends: note the various options legend("bottomleft", legend=mydata, lty = 1:3,col = plcols, pch = plchr, bty = "n", title = "Sample\nLegend Title") ## One line legend box legend("top", legend = mydata, lty = 1:3, col = plcols, pch = plchr, horiz = TRUE, inset = 0.01) Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

12 A Legend To A Plot More Options: Graph Continue... Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

13 Examples: Continue... ## numeric coordinates for legend box legend(8.2, 1.7, legend = mydata, lty = 1:3, col = plcols, pch = plchr, bg = "gray90") ## Two-column legend box legend("right", legend = mydata, lty = 1:3, col = plcols, pch=plchr, ncol=2, inset=0.01, title = "Two-column Layout") ## This time go for simple colored boxes legend(0, 8, legend = mydata, fill = plcols) ## Add a legend using the mouse to set the location ## Top left of legend appears where you click with the ## mouse legend(locator(1), legend= mydata, lty= 1:3,col = plcols) Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

14 A Legend To A Plot More Options: Graph Continue... Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

15 Two-dimensional gure: scatterplot (plot) plot(cars$dist,col=2,pch=16,cex=1.4,xlab="cars",ylab="frequenc points(cars$speed,col=3,cex=1.5) legend("topleft",c("dist.","speed"),pch=c(16,1), col=c(2,3),bg="gray90") title(main="speed and Stopping Distances of Cars") Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

16 Histograms (plot) hist(): This command creates histograms. The command computes the required values before plotting the histogram. Example: ## Make some data set.seed(99) # Set random number generator dat = rnorm(50, mean = 10, sd = 1.5) ## Draw histogram ## Extend x-axis limits, add density ## fill lines hist(dat, xlim = c(4, 14), density = 15, angle = 60) Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

17 Histogram of Random Normal Data plot Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

18 Two-Added Histograms (plot) hist(cars$speed, xlim=c(0,150), ylim=c(0,35), breaks= seq(0,150,10), col="skyblue", ylab= "Frequency", border= "pink", xlab="cars Frequences", main="speed and Stopping Distances of Cars") hist(cars$dist,xlim=c(0,150),ylim=c(0,35), breaks=seq(0,150,10), add=t, density=9) legend(115,35,legend=c("speed","distance"), fill=c("skyblue","black"), density=c(na,9)) box() Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

19 Added Histograms plot Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

20 Density curve plotted over a histogram Sometimes it's useful to plot a density curve over a histogram to help identify the distribution, or demonstrate the deviation between sample distributions and proposed population distributions: RandomData <- rnorm(1000) hist(randomdata, freq=false, col="brown2") curve(dnorm, add=true, col="blue4", lwd=2);box() Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

21 Pie Charts A pie() function is used to plot a pie charts graph. Let's start with a simple pie chart graphing the books vector. Consider the books vector with 6 values. The values in books are displayed as the areas of pie slices. books <- c(2, 4, 7, 5, 8, 10) Create a pie chart for books pie(books) Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

22 Pie Charts More Options As in a plot function, we can add many parameters to a pie function. Now let's add a heading, change the colors, and dene our own labels. pie(books, main="books", col=rainbow(length(books)), labels=c("mon","tue","wed","thu","fri","sat")) Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

23 Pie Charts More Options Now let us change the colors, label using percentages, and create a legend. Create a vector of heating colors. Calculate the percentage for each day, and round each value to one decimal place. Combine a "%" sign after each value. Then create the pie chart plot using pie function. Finally, create a legend at the right side of the plot. colors <- heat.colors(length(books)) book_labels <- round(books/sum(books) * 100, 1) book_labels <- paste(book_labels, "%", sep="") pie(books, main="books", col=colors, labels=book_labels, cex=0.8) legend(1.5, 0.5, c("mon","tue","wed","thu","fri"), cex=0.8, fill=colors) Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

24 Pie Charts Plot Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

25 Pie Charts Plot > pie(rep(1, 30), col = rainbow(30), radius = 0.9) Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

26 Multiple Plots on a Page The default is to have one plot per window. If you would like more, you can use the following command: par(mfrow=c(, ))(multi-gure, by row) Within the c(, ), choose how many rows and columns of pictures you would like. If you have four plots, par(mfrow=c(2,2)) 2 rows and 2 columns If you have six plots, par(mfrow=c(2,3)) or par(mfrow=c(3,2)). If you have fewer plots than spaces on the window, R will just leave the others blank. However, if you want to go back to one plot per window, you need to reset to par(mfrow=c(1,1)). Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

27 ## Set plot window into 6 (2 rows, 3 columns) opt = par(mfrow = c(2, 3)) ## Produce 6 color wheels as pie charts pie(rep(1,12), col = rainbow(12), radius = 0.95, main = "Rainbow Colors"); box(which = "figure") pie(rep(1,12), col = heat.colors(12), radius = 0.95, main = "Heat colors"); box(which = "figure") pie(rep(1,12), col = terrain.colors(12), radius = 0.95, main = "Terrain Colors"); box(which = "figure") pie(rep(1,12), col = topo.colors(12), radius = 0.95, main = "Topo Colors"); box(which = "figure") pie(rep(1,12), col = cm.colors(12), radius = 0.95, main = "CM Colors"); box(which = "figure") pie(rep(1,12),col = gray(seq(0,1,len=12)),radius = 0.95, main = "Gray Colors"); box(which = "figure") Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

28 Multi-Figure Mode Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

29 title(main = "Sine and Cosine functions") Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34 plot() with curve() functions in one gure mode type: ## First of all reset to one figure mode type ## use par(mfrow=c(1,1)) or easily par(opt) ## Plot a trig function ## curve command would give same result ## Set x-axis to go from -2*pi to +2*pi plot(sin, from = -pi*2, to = pi*2, lty = 2, lwd = 3, ylim = c(-1, 1.5), ylab = "y-value") ## Plot the cosine, use curve command and set ## add = TRUE to overlay curve(cos, from = -pi*2, to = pi*2, lty = 3,lwd = 3,add=T) ## Add a legend, be careful to styles from the plot legend("topright", legend = c("sine", "Cosine"), lty = c(2, 3), lwd = c(3, 3), bty = "n") ## Give a main title

30 Multi-Figure Mode Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

31 More math. Expressions with text curve(2 * exp(-x/2), from = 0, to = 7, ylim = c(0, 2), xlab = "", ylab = "",col=5, lwd=3) curve(2 * exp(-x), add = TRUE, lty = 4, col=4, lwd=3) curve(x * exp(-x/2), add= TRUE, lty = 2, col=2, lwd=3) curve(2 * x * exp(-x/2),add= TRUE,lty = 3,col=3,lwd=3) text(0.4, 1.9, expression(paste("exponential: ", 2 * e^(-x/2))),col=5, adj = 0) text(4, 0.7, expression(paste("ricker: ", x * e^(-x/2))),col=2) text(4, 1.25, expression(paste("ricker: ", 2 * x * e^(-x/2))),col=3,adj = 0) text(2.8, 0.12, expression(paste("exponential: ", 2 * e^(-x))),col=4) title( expression(paste("exp plots: ", 2 * e^(-x/2), x * e^(-x/2), 2 * x * e^(-x/2),2 * e^(-x) ))) Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

32 Exponential plots with expressions Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

33 Device Drivers By default, a window will automatically be opened to display your graphics. Some other devices available include postscript(), pdf(), png() and jpeg(). (See the help for Devices for a complete list.) To use an alternative driver, either call the appropriate function before plotting, or use the dev.copy() function to specify a device to which to copy the current plot, always ending with a call to dev.off(). For example, to create a PostScript plot, use statements like postscript(file="myplot.ps")... plotting commands go here... dev.off() To create a jpeg image from the currently displayed plot, use dev.copy(device=jpeg,file="picture.jpg") dev.off() Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

34 4 Histograms plot saving postscript("4gammaplot.ps") x <- seq(0, 30, length=300) gshape <- c(2, 5, 10, 15) colors <- c("red", "blue", "darkgreen", "gold") plot.new() plot.window(xlim=c(0,30),ylim=c(0,0.4)) axis(1); axis(2) for (i in 1:4){ lines(x, dgamma(x,shape=gshape[i], scale=1), lwd=2, col=colors[i])} # Inserting mathematical expressions text(3.5,.35, expression(paste(alpha==2))) text(6.5,.18, expression(paste(alpha==5))) text(11.5,.13, expression(paste(alpha==10))) text(23,.05, expression(paste(alpha==15))) dev.off() Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

35 4 Gamma plot saving dev.copy(device=pdf,file="4gammaplot.pdf") dev.off() The Saved plot looks like: Bisher M. Iqelan (IUG) Lecture 9: Basic graphics in R Part 2 1 st Semester / 34

36 End of lecture 8 Part(2). Thank you.!!!

IST 3108 Data Analysis and Graphics Using R Week 9

IST 3108 Data Analysis and Graphics Using R Week 9 IST 3108 Data Analysis and Graphics Using R Week 9 Engin YILDIZTEPE, Ph.D 2017-Spring Introduction to Graphics >y plot (y) In R, pictures are presented in the active graphical device or window.

More information

Plotting Complex Figures Using R. Simon Andrews v

Plotting Complex Figures Using R. Simon Andrews v Plotting Complex Figures Using R Simon Andrews simon.andrews@babraham.ac.uk v2017-11 The R Painters Model Plot area Base plot Overlays Core Graph Types Local options to change a specific plot Global options

More information

Intro to R Graphics Center for Social Science Computation and Research, 2010 Stephanie Lee, Dept of Sociology, University of Washington

Intro to R Graphics Center for Social Science Computation and Research, 2010 Stephanie Lee, Dept of Sociology, University of Washington Intro to R Graphics Center for Social Science Computation and Research, 2010 Stephanie Lee, Dept of Sociology, University of Washington Class Outline - The R Environment and Graphics Engine - Basic Graphs

More information

Graphics - Part III: Basic Graphics Continued

Graphics - Part III: Basic Graphics Continued Graphics - Part III: Basic Graphics Continued Statistics 135 Autumn 2005 Copyright c 2005 by Mark E. Irwin Highway MPG 20 25 30 35 40 45 50 y^i e i = y i y^i 2000 2500 3000 3500 4000 Car Weight Copyright

More information

R Workshop Module 3: Plotting Data Katherine Thompson Department of Statistics, University of Kentucky

R Workshop Module 3: Plotting Data Katherine Thompson Department of Statistics, University of Kentucky R Workshop Module 3: Plotting Data Katherine Thompson (katherine.thompson@uky.edu Department of Statistics, University of Kentucky October 15, 2013 Reading in Data Start by reading the dataset practicedata.txt

More information

AA BB CC DD EE. Introduction to Graphics in R

AA BB CC DD EE. Introduction to Graphics in R Introduction to Graphics in R Cori Mar 7/10/18 ### Reading in the data dat

More information

CIND123 Module 6.2 Screen Capture

CIND123 Module 6.2 Screen Capture CIND123 Module 6.2 Screen Capture Hello, everyone. In this segment, we will discuss the basic plottings in R. Mainly; we will see line charts, bar charts, histograms, pie charts, and dot charts. Here is

More information

INTRODUCTION TO R. Basic Graphics

INTRODUCTION TO R. Basic Graphics INTRODUCTION TO R Basic Graphics Graphics in R Create plots with code Replication and modification easy Reproducibility! graphics package ggplot2, ggvis, lattice graphics package Many functions plot()

More information

Data Visualization. Andrew Jaffe Instructor

Data Visualization. Andrew Jaffe Instructor Module 9 Data Visualization Andrew Jaffe Instructor Basic Plots We covered some basic plots previously, but we are going to expand the ability to customize these basic graphics first. 2/45 Read in Data

More information

Using Built-in Plotting Functions

Using Built-in Plotting Functions Workshop: Graphics in R Katherine Thompson (katherine.thompson@uky.edu Department of Statistics, University of Kentucky September 15, 2016 Using Built-in Plotting Functions ## Plotting One Quantitative

More information

Types of Plotting Functions. Managing graphics devices. Further High-level Plotting Functions. The plot() Function

Types of Plotting Functions. Managing graphics devices. Further High-level Plotting Functions. The plot() Function 3 / 23 5 / 23 Outline The R Statistical Environment R Graphics Peter Dalgaard Department of Biostatistics University of Copenhagen January 16, 29 1 / 23 2 / 23 Overview Standard R Graphics The standard

More information

Package areaplot. October 18, 2017

Package areaplot. October 18, 2017 Version 1.2-0 Date 2017-10-18 Package areaplot October 18, 2017 Title Plot Stacked Areas and Confidence Bands as Filled Polygons Imports graphics, grdevices, stats Suggests MASS Description Plot stacked

More information

Graphics in R Ira Sharenow January 2, 2019

Graphics in R Ira Sharenow January 2, 2019 Graphics in R Ira Sharenow January 2, 2019 library(ggplot2) # graphing library library(rcolorbrewer) # nice colors R Markdown This is an R Markdown document. The purpose of this document is to show R users

More information

Graphics in R STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley

Graphics in R STAT 133. Gaston Sanchez. Department of Statistics, UC Berkeley Graphics in R STAT 133 Gaston Sanchez Department of Statistics, UC Berkeley gastonsanchez.com github.com/gastonstat/stat133 Course web: gastonsanchez.com/stat133 Base Graphics 2 Graphics in R Traditional

More information

Introduction to R. Biostatistics 615/815 Lecture 23

Introduction to R. Biostatistics 615/815 Lecture 23 Introduction to R Biostatistics 615/815 Lecture 23 So far We have been working with C Strongly typed language Variable and function types set explicitly Functional language Programs are a collection of

More information

Statistics 251: Statistical Methods

Statistics 251: Statistical Methods Statistics 251: Statistical Methods Summaries and Graphs in R Module R1 2018 file:///u:/documents/classes/lectures/251301/renae/markdown/master%20versions/summary_graphs.html#1 1/14 Summary Statistics

More information

Error-Bar Charts from Summary Data

Error-Bar Charts from Summary Data Chapter 156 Error-Bar Charts from Summary Data Introduction Error-Bar Charts graphically display tables of means (or medians) and variability. Following are examples of the types of charts produced by

More information

Az R adatelemzési nyelv

Az R adatelemzési nyelv Az R adatelemzési nyelv alapjai II. Egészségügyi informatika és biostatisztika Gézsi András gezsi@mit.bme.hu Functions Functions Functions do things with data Input : function arguments (0,1,2, ) Output

More information

DSCI 325: Handout 18 Introduction to Graphics in R

DSCI 325: Handout 18 Introduction to Graphics in R DSCI 325: Handout 18 Introduction to Graphics in R Spring 2016 This handout will provide an introduction to creating graphics in R. One big advantage that R has over SAS (and over several other statistical

More information

Advanced Graphics with R

Advanced Graphics with R Advanced Graphics with R Paul Murrell Universitat de Barcelona April 30 2009 Session overview: (i) Introduction Graphic formats: Overview and creating graphics in R Graphical parameters in R: par() Selected

More information

Statistical Programming Camp: An Introduction to R

Statistical Programming Camp: An Introduction to R Statistical Programming Camp: An Introduction to R Handout 3: Data Manipulation and Summarizing Univariate Data Fox Chapters 1-3, 7-8 In this handout, we cover the following new materials: ˆ Using logical

More information

An Introduction to R 2.2 Statistical graphics

An Introduction to R 2.2 Statistical graphics An Introduction to R 2.2 Statistical graphics Dan Navarro (daniel.navarro@adelaide.edu.au) School of Psychology, University of Adelaide ua.edu.au/ccs/people/dan DSTO R Workshop, 29-Apr-2015 Scatter plots

More information

Module 10. Data Visualization. Andrew Jaffe Instructor

Module 10. Data Visualization. Andrew Jaffe Instructor Module 10 Data Visualization Andrew Jaffe Instructor Basic Plots We covered some basic plots on Wednesday, but we are going to expand the ability to customize these basic graphics first. 2/37 But first...

More information

STATISTICS: AN INTRODUCTION USING R. By M.J. Crawley. Exercises 1. PLOTS: GRAPHICAL METHODS OF DATA EXPLORATION

STATISTICS: AN INTRODUCTION USING R. By M.J. Crawley. Exercises 1. PLOTS: GRAPHICAL METHODS OF DATA EXPLORATION STATISTICS: AN INTRODUCTION USING R By M.J. Crawley Exercises 1. PLOTS: GRAPHICAL METHODS OF DATA EXPLORATION Producing high quality graphs is one of the main reasons for doing statistical computing. There

More information

Advanced Econometric Methods EMET3011/8014

Advanced Econometric Methods EMET3011/8014 Advanced Econometric Methods EMET3011/8014 Lecture 2 John Stachurski Semester 1, 2011 Announcements Missed first lecture? See www.johnstachurski.net/emet Weekly download of course notes First computer

More information

Basics of Plotting Data

Basics of Plotting Data Basics of Plotting Data Luke Chang Last Revised July 16, 2010 One of the strengths of R over other statistical analysis packages is its ability to easily render high quality graphs. R uses vector based

More information

Package EnQuireR. R topics documented: February 19, Type Package Title A package dedicated to questionnaires Version 0.

Package EnQuireR. R topics documented: February 19, Type Package Title A package dedicated to questionnaires Version 0. Type Package Title A package dedicated to questionnaires Version 0.10 Date 2009-06-10 Package EnQuireR February 19, 2015 Author Fournier Gwenaelle, Cadoret Marine, Fournier Olivier, Le Poder Francois,

More information

Introduction to RStudio

Introduction to RStudio First, take class through processes of: Signing in Changing password: Tools -> Shell, then use passwd command Installing packages Check that at least these are installed: MASS, ISLR, car, class, boot,

More information

Plotting: An Iterative Process

Plotting: An Iterative Process Plotting: An Iterative Process Plotting is an iterative process. First we find a way to represent the data that focusses on the important aspects of the data. What is considered an important aspect may

More information

The Basics of Plotting in R

The Basics of Plotting in R The Basics of Plotting in R R has a built-in Datasets Package: iris mtcars precip faithful state.x77 USArrests presidents ToothGrowth USJudgeRatings You can call built-in functions like hist() or plot()

More information

Bar Charts and Frequency Distributions

Bar Charts and Frequency Distributions Bar Charts and Frequency Distributions Use to display the distribution of categorical (nominal or ordinal) variables. For the continuous (numeric) variables, see the page Histograms, Descriptive Stats

More information

BIMM-143: INTRODUCTION TO BIOINFORMATICS (Lecture 5)

BIMM-143: INTRODUCTION TO BIOINFORMATICS (Lecture 5) BIMM-143: INTRODUCTION TO BIOINFORMATICS (Lecture 5) Data exploration and visualization in R https://bioboot.github.io/bimm143_w18/lectures/#5 Dr. Barry Grant Overview: One of the biggest attractions to

More information

Package visualizationtools

Package visualizationtools Package visualizationtools April 12, 2011 Type Package Title Package contains a few functions to visualize statistical circumstances. Version 0.2 Date 2011-04-06 Author Thomas Roth Etienne Stockhausen

More information

Graphics #1. R Graphics Fundamentals & Scatter Plots

Graphics #1. R Graphics Fundamentals & Scatter Plots Graphics #1. R Graphics Fundamentals & Scatter Plots In this lab, you will learn how to generate customized publication-quality graphs in R. Working with R graphics can be done as a stepwise process. Rather

More information

An Introduction to R Graphics with examples

An Introduction to R Graphics with examples An Introduction to R Graphics with examples Feng Li November 18, 2008 1 R graphics system A picture is worth a thousand words! The R graphics system can be broken into four distinct levels: graphics packages;

More information

Recap From Last Time: Today s Learning Goals. Today s Learning Goals BIMM 143. Data visualization with R. Lecture 5. Barry Grant

Recap From Last Time: Today s Learning Goals. Today s Learning Goals BIMM 143. Data visualization with R. Lecture 5. Barry Grant BIMM 143 Data visualization with R Lecture 5 Barry Grant http://thegrantlab.org/bimm143 Recap From Last Time: What is R and why should we use it? Familiarity with R s basic syntax. Familiarity with major

More information

Configuring Figure Regions with prepplot Ulrike Grömping 03 April 2018

Configuring Figure Regions with prepplot Ulrike Grömping 03 April 2018 Configuring Figure Regions with prepplot Ulrike Grömping 3 April 218 Contents 1 Purpose and concept of package prepplot 1 2 Overview of possibilities 2 2.1 Scope.................................................

More information

Lab 1 Introduction to R

Lab 1 Introduction to R Lab 1 Introduction to R Date: August 23, 2011 Assignment and Report Due Date: August 30, 2011 Goal: The purpose of this lab is to get R running on your machines and to get you familiar with the basics

More information

Excel R Tips. is used for multiplication. + is used for addition. is used for subtraction. / is used for division

Excel R Tips. is used for multiplication. + is used for addition. is used for subtraction. / is used for division Excel R Tips EXCEL TIP 1: INPUTTING FORMULAS To input a formula in Excel, click on the cell you want to place your formula in, and begin your formula with an equals sign (=). There are several functions

More information

GS Analysis of Microarray Data

GS 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 information

R Graphics. Feng Li School of Statistics and Mathematics Central University of Finance and Economics

R Graphics. Feng Li School of Statistics and Mathematics Central University of Finance and Economics R Graphics Feng Li feng.li@cufe.edu.cn School of Statistics and Mathematics Central University of Finance and Economics Revised on June 2, 2015 Today we are going to learn... 1 Basic R Graphical System

More information

An Introduction to R Graphics

An Introduction to R Graphics An Introduction to R Graphics PnP Group Seminar 25 th April 2012 Why use R for graphics? Fast data exploration Easy automation and reproducibility Create publication quality figures Customisation of almost

More information

Continuous-time stochastic simulation of epidemics in R

Continuous-time stochastic simulation of epidemics in R Continuous-time stochastic simulation of epidemics in R Ben Bolker May 16, 2005 1 Introduction/basic code Using the Gillespie algorithm, which assumes that all the possible events that can occur (death

More information

Combo Charts. Chapter 145. Introduction. Data Structure. Procedure Options

Combo Charts. Chapter 145. Introduction. Data Structure. Procedure Options Chapter 145 Introduction When analyzing data, you often need to study the characteristics of a single group of numbers, observations, or measurements. You might want to know the center and the spread about

More information

Exploratory Data Analysis - Part 2 September 8, 2005

Exploratory Data Analysis - Part 2 September 8, 2005 Exploratory Data Analysis - Part 2 September 8, 2005 Exploratory Data Analysis - Part 2 p. 1/20 Trellis Plots Trellis plots (S-Plus) and Lattice plots in R also create layouts for multiple plots. A trellis

More information

Part I - WORKING WITH ABSOLUTE REFERENCES

Part I - WORKING WITH ABSOLUTE REFERENCES INTRODUCTION TO COMPUTER CONCEPTS CSIT 100 LAB: MORE WORK with MS EXCEL Part I - WORKING WITH ABSOLUTE REFERENCES This is an implementation of a spreadsheet program. It contains 1,048,576 rows, and 16,384

More information

R Graph Essentials. Use R's powerful graphing capabilities to design and create professional-level graphics. David Alexander Lillis

R Graph Essentials. Use R's powerful graphing capabilities to design and create professional-level graphics. David Alexander Lillis R Graph Essentials Use R's powerful graphing capabilities to design and create professional-level graphics David Alexander Lillis BIRMINGHAM - MUMBAI R Graph Essentials Copyright 2014 Packt Publishing

More information

Package arphit. March 28, 2019

Package arphit. March 28, 2019 Type Package Title RBA-style R Plots Version 0.3.1 Author Angus Moore Package arphit March 28, 2019 Maintainer Angus Moore Easily create RBA-style graphs

More information

plot(seq(0,10,1), seq(0,10,1), main = "the Title", xlim=c(1,20), ylim=c(1,20), col="darkblue");

plot(seq(0,10,1), seq(0,10,1), main = the Title, xlim=c(1,20), ylim=c(1,20), col=darkblue); R for Biologists Day 3 Graphing and Making Maps with Your Data Graphing is a pretty convenient use for R, especially in Rstudio. plot() is the most generalized graphing function. If you give it all numeric

More information

R Graphics. Paul Murrell. The University of Auckland. R Graphics p.1/47

R Graphics. Paul Murrell. The University of Auckland. R Graphics p.1/47 R Graphics p.1/47 R Graphics Paul Murrell paul@stat.auckland.ac.nz The University of Auckland R Graphics p.2/47 Overview Standard (base) R graphics grid graphics Graphics Regions and Coordinate Systems

More information

Introduction to R 21/11/2016

Introduction 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 information

Package pwrrasch. R topics documented: September 28, Type Package

Package pwrrasch. R topics documented: September 28, Type Package Type Package Package pwrrasch September 28, 2015 Title Statistical Power Simulation for Testing the Rasch Model Version 0.1-2 Date 2015-09-28 Author Takuya Yanagida [cre, aut], Jan Steinfeld [aut], Thomas

More information

Introduction to Plot.ly: Customizing a Stacked Bar Chart

Introduction to Plot.ly: Customizing a Stacked Bar Chart Introduction to Plot.ly: Customizing a Stacked Bar Chart Plot.ly is a free web data visualization tool that allows you to download and embed your charts on other websites. This tutorial will show you the

More information

This document is designed to get you started with using R

This 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 information

Making plots in R [things I wish someone told me when I started grad school]

Making plots in R [things I wish someone told me when I started grad school] Making plots in R [things I wish someone told me when I started grad school] Kirk Lohmueller Department of Ecology and Evolutionary Biology UCLA September 22, 2017 In honor of Talk Like a Pirate Day...

More information

Lastly, in case you don t already know this, and don t have Excel on your computers, you can get it for free through IT s website under software.

Lastly, in case you don t already know this, and don t have Excel on your computers, you can get it for free through IT s website under software. Welcome to Basic Excel, presented by STEM Gateway as part of the Essential Academic Skills Enhancement, or EASE, workshop series. Before we begin, I want to make sure we are clear that this is by no means

More information

Package SCBmeanfd. December 27, 2016

Package SCBmeanfd. December 27, 2016 Type Package Package SCBmeanfd December 27, 2016 Title Simultaneous Confidence Bands for the Mean of Functional Data Version 1.2.2 Date 2016-12-22 Author David Degras Maintainer David Degras

More information

Package Grid2Polygons

Package Grid2Polygons Package Grid2Polygons February 15, 2013 Version 0.1-2 Date 2013-01-28 Title Convert Spatial Grids to Polygons Author Jason C. Fisher Maintainer Jason C. Fisher Depends R (>= 2.15.0),

More information

Statistical Programming with R

Statistical Programming with R Statistical Programming with R Lecture 5: Simple Programming Bisher M. Iqelan biqelan@iugaza.edu.ps Department of Mathematics, Faculty of Science, The Islamic University of Gaza 2017-2018, Semester 1 Functions

More information

Introduction to R for Beginners, Level II. Jeon Lee Bio-Informatics Core Facility (BICF), UTSW

Introduction to R for Beginners, Level II. Jeon Lee Bio-Informatics Core Facility (BICF), UTSW Introduction to R for Beginners, Level II Jeon Lee Bio-Informatics Core Facility (BICF), UTSW Basics of R Powerful programming language and environment for statistical computing Useful for very basic analysis

More information

Exploratory Projection Pursuit

Exploratory Projection Pursuit Exploratory Projection Pursuit (Jerome Friedman, PROJECTION PURSUIT METHODS FOR DATA ANALYSIS, June. 1980, SLAC PUB-2768) Read in required files drive - D: code.dir - paste(drive, DATA/Data Mining R-Code,

More information

Package Calculator.LR.FNs

Package Calculator.LR.FNs Type Package Package Calculator.LR.FNs Title Calculator for LR Fuzzy Numbers Version 1.3 Date 2018-05-01 May 2, 2018 Author Abbas Parchami (Department of Statistics, Faculty of Mathematics and Computer,

More information

Introduction Basics Simple Statistics Graphics. Using R for Data Analysis and Graphics. 4. Graphics

Introduction Basics Simple Statistics Graphics. Using R for Data Analysis and Graphics. 4. Graphics Using R for Data Analysis and Graphics 4. Graphics Overview 4.1 Overview Several R graphics functions have been presented so far: > plot(d.sport[,"kugel"], d.sport[,"speer"], + xlab="ball push", ylab="javelin",

More information

The first one will centre the data and ensure unit variance (i.e. sphere the data):

The first one will centre the data and ensure unit variance (i.e. sphere the data): SECTION 5 Exploratory Projection Pursuit We are now going to look at an exploratory tool called projection pursuit (Jerome Friedman, PROJECTION PURSUIT METHODS FOR DATA ANALYSIS, June. 1980, SLAC PUB-2768)

More information

Introduction to R for Epidemiologists

Introduction to R for Epidemiologists Introduction to R for Epidemiologists Jenna Krall, PhD Thursday, January 29, 2015 Final project Epidemiological analysis of real data Must include: Summary statistics T-tests or chi-squared tests Regression

More information

Fathom Dynamic Data TM Version 2 Specifications

Fathom Dynamic Data TM Version 2 Specifications Data Sources Fathom Dynamic Data TM Version 2 Specifications Use data from one of the many sample documents that come with Fathom. Enter your own data by typing into a case table. Paste data from other

More information

Chapter 5 An Introduction to Basic Plotting Tools

Chapter 5 An Introduction to Basic Plotting Tools Chapter 5 An Introduction to Basic Plotting Tools We have demonstrated the use of R tools for importing data, manipulating data, extracting subsets of data, and making simple calculations, such as mean,

More information

Assignments. Math 338 Lab 1: Introduction to R. Atoms, Vectors and Matrices

Assignments. Math 338 Lab 1: Introduction to R. Atoms, Vectors and Matrices Assignments Math 338 Lab 1: Introduction to R. Generally speaking, there are three basic forms of assigning data. Case one is the single atom or a single number. Assigning a number to an object in this

More information

Package sciplot. February 15, 2013

Package sciplot. February 15, 2013 Package sciplot February 15, 2013 Version 1.1-0 Title Scientific Graphing Functions for Factorial Designs Author Manuel Morales , with code developed by the R Development Core Team

More information

EXCEL 2003 DISCLAIMER:

EXCEL 2003 DISCLAIMER: EXCEL 2003 DISCLAIMER: This reference guide is meant for experienced Microsoft Excel users. It provides a list of quick tips and shortcuts for familiar features. This guide does NOT replace training or

More information

Stat 290: Lab 2. Introduction to R/S-Plus

Stat 290: Lab 2. Introduction to R/S-Plus Stat 290: Lab 2 Introduction to R/S-Plus Lab Objectives 1. To introduce basic R/S commands 2. Exploratory Data Tools Assignment Work through the example on your own and fill in numerical answers and graphs.

More information

Dr. Junchao Xia Center of Biophysics and Computational Biology. Fall /6/ /13

Dr. Junchao Xia Center of Biophysics and Computational Biology. Fall /6/ /13 BIO5312 Biostatistics R Session 02: Graph Plots in R Dr. Junchao Xia Center of Biophysics and Computational Biology Fall 2016 9/6/2016 1 /13 Graphic Methods Graphic methods of displaying data give a quick

More information

Topics for today Input / Output Using data frames Mathematics with vectors and matrices Summary statistics Basic graphics

Topics for today Input / Output Using data frames Mathematics with vectors and matrices Summary statistics Basic graphics Topics for today Input / Output Using data frames Mathematics with vectors and matrices Summary statistics Basic graphics Introduction to S-Plus 1 Input: Data files For rectangular data files (n rows,

More information

Chapter 2: Descriptive Statistics: Tabular and Graphical Methods

Chapter 2: Descriptive Statistics: Tabular and Graphical Methods Chapter 2: Descriptive Statistics: Tabular and Graphical Methods Example 1 C2_1

More information

HOUR 12. Adding a Chart

HOUR 12. Adding a Chart HOUR 12 Adding a Chart The highlights of this hour are as follows: Reasons for using a chart The chart elements The chart types How to create charts with the Chart Wizard How to work with charts How to

More information

Univariate Data - 2. Numeric Summaries

Univariate Data - 2. Numeric Summaries Univariate Data - 2. Numeric Summaries Young W. Lim 2018-08-01 Mon Young W. Lim Univariate Data - 2. Numeric Summaries 2018-08-01 Mon 1 / 36 Outline 1 Univariate Data Based on Numerical Summaries R Numeric

More information

Creating a Basic Chart in Excel 2007

Creating a Basic Chart in Excel 2007 Creating a Basic Chart in Excel 2007 A chart is a pictorial representation of the data you enter in a worksheet. Often, a chart can be a more descriptive way of representing your data. As a result, those

More information

Graph tool instructions and R code

Graph tool instructions and R code Graph tool instructions and R code 1) Prepare data: tab-delimited format Data need to be inputted in a tab-delimited format. This can be easily achieved by preparing the data in a spread sheet program

More information

Math 121 Project 4: Graphs

Math 121 Project 4: Graphs Math 121 Project 4: Graphs Purpose: To review the types of graphs, and use MS Excel to create them from a dataset. Outline: You will be provided with several datasets and will use MS Excel to create graphs.

More information

Introduction to R: Day 2 September 20, 2017

Introduction to R: Day 2 September 20, 2017 Introduction to R: Day 2 September 20, 2017 Outline RStudio projects Base R graphics plotting one or two continuous variables customizable elements of plots saving plots to a file Create a new project

More information

An introduction to WS 2015/2016

An introduction to WS 2015/2016 An introduction to WS 2015/2016 Dr. Noémie Becker (AG Metzler) Dr. Sonja Grath (AG Parsch) Special thanks to: Prof. Dr. Martin Hutzenthaler (previously AG Metzler, now University of Duisburg-Essen) course

More information

LECTURE 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 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 information

FlowJo Software Lecture Outline:

FlowJo Software Lecture Outline: FlowJo Software Lecture Outline: Workspace Basics: 3 major components 1) The Ribbons (toolbar) The availability of buttons here can be customized. *One of the best assets of FlowJo is the help feature*

More information

Install RStudio from - use the standard installation.

Install RStudio from   - use the standard installation. Session 1: Reading in Data Before you begin: Install RStudio from http://www.rstudio.com/ide/download/ - use the standard installation. Go to the course website; http://faculty.washington.edu/kenrice/rintro/

More information

R is a programming language of a higher-level Constantly increasing amount of packages (new research) Free of charge Website:

R is a programming language of a higher-level Constantly increasing amount of packages (new research) Free of charge Website: Introduction to R R R is a programming language of a higher-level Constantly increasing amount of packages (new research) Free of charge Website: http://www.r-project.org/ Code Editor: http://rstudio.org/

More information

0 Graphical Analysis Use of Excel

0 Graphical Analysis Use of Excel Lab 0 Graphical Analysis Use of Excel What You Need To Know: This lab is to familiarize you with the graphing ability of excels. You will be plotting data set, curve fitting and using error bars on the

More information

Package desplot. R topics documented: April 3, 2018

Package desplot. R topics documented: April 3, 2018 Package desplot April 3, 2018 Title Plotting Field Plans for Agricultural Experiments Version 1.4 Date 2018-04-02 Type Package Description A function for plotting maps of agricultural field experiments

More information

The nor1mix Package. August 3, 2006

The nor1mix Package. August 3, 2006 The nor1mix Package August 3, 2006 Title Normal (1-d) Mixture Models (S3 Classes and Methods) Version 1.0-6 Date 2006-08-02 Author: Martin Mächler Maintainer Martin Maechler

More information

LAB #1: DESCRIPTIVE STATISTICS WITH R

LAB #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 information

From Getting Started with the Graph Template Language in SAS. Full book available for purchase here.

From Getting Started with the Graph Template Language in SAS. Full book available for purchase here. From Getting Started with the Graph Template Language in SAS. Full book available for purchase here. Contents About This Book... xi About The Author... xv Acknowledgments...xvii Chapter 1: Introduction

More information

> glucose = c(81, 85, 93, 93, 99, 76, 75, 84, 78, 84, 81, 82, 89, + 81, 96, 82, 74, 70, 84, 86, 80, 70, 131, 75, 88, 102, 115, + 89, 82, 79, 106)

> glucose = c(81, 85, 93, 93, 99, 76, 75, 84, 78, 84, 81, 82, 89, + 81, 96, 82, 74, 70, 84, 86, 80, 70, 131, 75, 88, 102, 115, + 89, 82, 79, 106) This document describes how to use a number of R commands for plotting one variable and for calculating one variable summary statistics Specifically, it describes how to use R to create dotplots, histograms,

More information

Make sure to keep all graphs in same excel file as your measures.

Make sure to keep all graphs in same excel file as your measures. Project Part 2 Graphs. I. Use Excel to make bar graph for questions 1, and 5. II. Use Excel to make histograms for questions 2, and 3. III. Use Excel to make pie graphs for questions 4, and 6. IV. Use

More information

Statistical Software Camp: Introduction to R

Statistical 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 information

Desktop Studio: Charts. Version: 7.3

Desktop Studio: Charts. Version: 7.3 Desktop Studio: Charts Version: 7.3 Copyright 2015 Intellicus Technologies This document and its content is copyrighted material of Intellicus Technologies. The content may not be copied or derived from,

More information

The LDheatmap Package

The LDheatmap Package The LDheatmap Package May 6, 2006 Title Graphical display of pairwise linkage disequilibria between SNPs Version 0.2-1 Author Ji-Hyung Shin , Sigal Blay , Nicholas Lewin-Koh

More information

A Handbook of Statistical Analyses Using R. Brian S. Everitt and Torsten Hothorn

A Handbook of Statistical Analyses Using R. Brian S. Everitt and Torsten Hothorn A Handbook of Statistical Analyses Using R Brian S. Everitt and Torsten Hothorn CHAPTER 7 Density Estimation: Erupting Geysers and Star Clusters 7.1 Introduction 7.2 Density Estimation The three kernel

More information

Microsoft Excel 2000 Charts

Microsoft Excel 2000 Charts You see graphs everywhere, in textbooks, in newspapers, magazines, and on television. The ability to create, read, and analyze graphs are essential parts of a student s education. Creating graphs by hand

More information

Practical 2: Plotting

Practical 2: Plotting Practical 2: Plotting Complete this sheet as you work through it. If you run into problems, then ask for help - don t skip sections! Open Rstudio and store any files you download or create in a directory

More information

Visualizing in R advanced plotting

Visualizing in R advanced plotting Visualizing in R advanced plotting Norsk statistikermøte, Halden, 10. juni 2013 Elisabeth Orskaug Thordis Thorarinsdottir Norsk Regnesentral 1 / 22 Outline of the lectures Monday Lecture I: Basic plotting

More information

Package qrfactor. February 20, 2015

Package qrfactor. February 20, 2015 Type Package Package qrfactor February 20, 2015 Title Simultaneous simulation of Q and R mode factor analyses with Spatial data Version 1.4 Date 2014-01-02 Author George Owusu Maintainer

More information