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 <- merge(bocaccioData,

Slides:



Advertisements
Similar presentations
Use Tables for Layout Control Day 7. You will learn to: Understand Tables Create a Simple Table Modify Your Tables Appearance Create Page Layouts with.
Advertisements

Chapter 3 – Web Design Tables & Page Layout
Chapter 9 Working with Tabs and Tables. Chapter Objectives Work with tabs Create and format a table Format text in a table Place graphics in a table.
Internet Basics & Way Beyond!
Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
Graphics in R data analysis and visualization Katia Oleinik Scientific Computing and Visualization Boston University
Lecture 1: Beautiful graphics in R
® Microsoft Office 2010 Excel Tutorial 4: Enhancing a Workbook with Charts and Graphs.
FIRST COURSE Excel Tutorial 4 Working with Charts and Graphics.
Graphing With Excel 2010 University of Michigan – Dearborn Science Learning Center Based on a presentation by James Golen Revised by Annette Sieg…
Visualization and Data Mining. 2 Outline  Graphical excellence and lie factor  Representing data in 1,2, and 3-D  Representing data in 4+ dimensions.
Using HTML Tables.
FISH 397C Winter 2009 Evan Girvetz More Complex Graphics in R © R Foundation, from
COMPREHENSIVE Excel Tutorial 4 Working with Charts and Graphics.
Using Charts in a Presentation Lesson 6. Software Orientation Charts can help your audience understand relationships among numerical values. The figure.
1 Create a Questionnaire Learning Objective  To learn how to use the features in Microsoft Publisher to create a questionnaire.
FIRST COURSE Excel Lecture. XP 2 Introducing Excel Microsoft Office Excel 2007 (or Excel) is a computer program used to enter, analyze, and present quantitative.
Instructor: Professor Cora Martinez, PhD Department of Civil and Environmental Engineering Florida International University.
Working with Layouts and Graphics. 1. The layout of a slide can be changed at any time during the creation of the presentation. 2. Various types of slide.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
Tutorial 4: Using CSS for Page Layout. 2 Objectives Session 4.1 Explore CSS layout Compare types of floating layouts Examine code for CSS layouts View.
11 Exploring Microsoft Office Excel 2007 Chapter 4: Working with Large Worksheets and Tables Chapter 04 - Lecture Notes (CSIT 104)
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.
CHAPTER 13 Creating a Workbook Part 1. Learning Objectives Understand spreadsheets and Excel Enter data in cells Edit cell content Work with columns and.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
XP New Perspectives on Microsoft Word 2002 Tutorial 31 Microsoft Word 2002 Tutorial 3 – Creating a Multiple-Page Report.
WORKBOOK FORMATTING Nolan Tomboulian Tomboulian.wikispaces.com HOW THINGS LOOK CELL COLORFONT COLOR CELL BORDERSFONT SIZE CELL SIZEFONT.
Designing a Web Page with Tables. A text table: contains only text, evenly spaced on the Web page in rows and columns uses only standard word processing.
Word 2010 Vocabulary List 1. Click and Type - A feature that allows you to double-click a blank area of a document to position the cursor in that location,
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.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
Copyright 2002, Paradigm Publishing Inc. CHAPTER 18 BACKNEXTEND 18-1 LINKS TO OBJECTIVES Creating a Chart Sizing and Moving a Chart Sizing and Moving a.
CIS234A- Lecture 7 Instructor Greg D’Andrea. Tables A table can be displayed on a Web page either in a text or graphical format. A text table: – contains.
1 CSE 2337 Chapter 3 Data Visualization With Excel.
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.
Adobe Photoshop CS5 – Illustrated Unit A: Getting Started with Photoshop CS5.
Plotting Complex Figures Using R
1. Tables, Charts, and Graphs Microsoft Word & Excel 2003.
Lesson 6 Formatting Cells and Ranges. Objectives:  Insert and delete cells  Manually format cell contents  Copy cell formatting with the Format Painter.
By: Ms. Abeer Helwa 1. WORD WEB APP 2 Word Web App is a limited version of Word, enabling you to edit, format, and share documents online. Word Web App.
Key Applications Module Lesson 14 — Working with Tables Computer Literacy BASICS.
Data Visualization.
Positioning Objects with CSS and Tables
Microsoft® Access Generate forms quickly 1 Modify controls in Layout View 2 Work with form sections 3 Modify controls in Design View 4 Add calculated.
Computer Literacy BASICS: A Comprehensive Guide to IC 3, 5 th Edition Lesson 18 Getting Started with Excel Essentials 1 Morrison / Wells / Ruffolo.
Data & Graphing vectors data frames importing data contingency tables barplots 18 September 2014 Sherubtse Training.
ADOBE INDESIGN CS3 Chapter 9 WORKING WITH TABS AND TABLES.
Excel Part 4 Working with Charts and Graphics. XP Objectives Create an embedded chart Work with chart titles and legends Create and format a pie chart.
Excel Part 4 Working with Charts and Graphics. XP Objectives Create an embedded chart Work with chart titles and legends Create and format a pie chart.
Creating Charts Ms. Hall Spring Using the Insert Tab to Create Charts The Insert tab contains the command groups you’ll use to create charts in.
Introduction to plotting data Fish 552: Lecture 4.
Tutorial 5 Working with Web Tables. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Learn and Apply the structure of.
More Complex Graphics in R Fish 552: Lecture 8. Recommended Readings How to Display Data Badly (Howard Wainer, 1984) –
MANAGING TEXT FLOW Lesson 5. OBJECTIVES SOFTWARE ORIENTATION The Page Layout tab contains groups of commands that will produce a formatted document’s.
Review > x[-c(1,4,6)] > Y[1:3,2:8] > island.data fishData$weight[1] > fishData[fishData$weight < 20 & fishData$condition.
Microsoft® PowerPoint  From the Insert tab, in the Tables group, click the Insert Table button.  Drag your pointer down and across to define.
Creating a Workbook Part 1
Using R Graphs in R.
Positioning Objects with CSS and Tables
Working with Tabs and Tables
Excel Part 4 Working with Charts and Graphics
Discriminant Analysis
Excel Part 4 Working with Charts and Graphics
Lecture 5 advanced multipanel plots
INTRODUCTION TO ADOBE ILLUSTRATOR
Chapter 5 Microsoft Excel Window
Floating and Positioning
Positioning Objects with CSS and Tables
Excel Part 4 Working with Charts and Graphics
Presentation transcript:

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 <- merge(bocaccioData, tripData, by.x="TripNum", by.y="SimplifiedTripNum") First few lines of data frame Frequency of elements Each element in the other vector? Find all partial matches Merging two datasets

Lecture 8 More complex graphics Trevor A. Branch FISH 552 Introduction to R

Box plots Martin ArosteguiJane Fencl

Bar plots Elyse HopeChristopher Johnson

Lines and points Thiago Couto Hannah Bassett

Aims To explore more of the options in R contained in par Create more informative plots Layouts for multiple plots Boxplots Barplots

Readings Wainer H (1984) How to display data badly. The American Statistician 38: – Tufte ER (2001) The visual display of quantitative information. Second edition. Graphics Press, Cheshire, Connecticut FISH 554 Beautiful Graphics in R (lectures, etc. online) –

Possum data Possum data come from the DAAG package Download from Canvas: Data files\possum.csv > possum <- read.csv(file="Data\\possum.csv") > head(possum,n=3) X case site Pop sex age hdlngth skullw totlngth 1 C3 1 1 Vic m C5 2 1 Vic f C Vic f taill footlgth earconch eye chest belly

Possum data case : observation number site : one of seven locations where possums were trapped Pop : a factor which classifies the sites as Vic Victoria, other New South Wales or Queensland sex : a factor with levels f female, m male age : age hdlngth : head length skullw : skull width totlngth : total length taill : tail length footlgth : foot length earconch : ear conch length eye : distance from medial canthus to lateral canthus of right eye chest : chest girth (in cm) belly : belly girth (in cm)

Multiple graphs It is often very useful to plot multiple graphs together Simple way: create a matrix of plots using par(mfrow=c(nr, nc)) or par(mfcol=c(nr, nc)) – Require a vector of the number of rows and number of colums: c(nr, nc) – To fill by row use mfrow – To fill by column use mfcol Must specify the par(mfrow=c(nr, nc)) command before making the plots

par(mfcol=c(2,3))

Edward Tufte’s rules Maximize the data:ink ratio Erase non-data ink Increase the data density Label the figures, avoid using legends Tufte ER (2001) The visual display of quantitative information. 2 nd ed. Graphics Press, Cheshire, Connecticut

Data-ink is in blue

Redundant parts and wasted space

Changing the margins When multiple plots are laid out, space can be optimized by modifying margins around each plot par(mar = c(bottom, left, top, right)) – Default is par(mar = c(5,4,4,2) + 0.1) To change the margins around the entire figure, use this command: par(oma = c(bottom, left, top, right)) – Default is par(oma = c(0,0,0,0))

par(mar=c(0,0,0,0), oma=c(5,5,1,1))

Deleting axes, adding labels To eliminate x or y axes or both, add to each individual plot plot(..., xaxt="n", yaxt="n") To add text to the outside of an individual plot, use a standalone command mtext after a single plot mtext(text="Foot length (cm)", side=2, line=3) To add text to the outside of multiple figures, use mtext with the outer=T option mtext(text="Year", side=1, line=3, outer=T) Values for side of the plot refer to 1=bottom, 2=left, 3=top, 4=right

Hands-on exercise 1 (starting code) possum <- read.csv(file="possum.csv") par(mfcol=c(2,3)) plot(possum$totlngth, possum$footlgth) plot(possum$totlngth, possum$hdlngth) plot(possum$skullw, possum$footlgth) plot(possum$skullw, possum$hdlngth) plot(possum$chest, possum$footlgth) plot(possum$chest, possum$hdlngth)

Exercise 1: Modify the code using mar, oma, xaxt, yaxt, and mtext to create the plot below. Take it one step at a time! If you have time, beautify it further.

Customized layouts The layout() function provides a much more flexible alternative to mfrow and mfcol settings The primary difference is that layout() allows the creation of multiple figure regions of unequal sizes The first argument is a matrix with the same number of rows and columns as in the figure layout In the matrix are integer values determining the rows and columns each figure will occupy

layout() layout(mat, widths, heights,...) mat a matrix giving the location of the next N figures on the output device. Each value in the matrix must be 0 or a positive integer. If N is the biggest number in the matrix, then the number 1,..., N-1 must also appear in the matrix. widths a vector of values for the widths of columns on the device. heights a vector of values for the heights of rows on the device.

mat <- matrix(c( 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,15), nrow=3, ncol=5, byrow=T) layout(mat=mat, widths = c(1,3,5,1,3), heights = c(2,2,1) ) layout.show(n=15) 15 plots different widths and heights

15 plots

Complex arrangement mat <- matrix(c( 1, 1, 3, 4, 5, 1, 1, 3, 6, 7, 2, 2, 2, 2, 7), nrow=3, ncol=5, byrow=T) layout(mat=mat, widths = c(1,3,5,1,3), heights = c(2,2,1) ) layout.show(n=7)

Complex arrangement

Zeros for empty plots

A published example

Worm et al. (2009) Rebuilding global fisheries. Science 325: Then plot the figures...

Clear the plots after layout() You will need to clear the plotting window to go back to normal plots after using mfrow or layout(). In code, use graphics.off(). Or...

Boxplots > catches <- read.csv("FAO catch.csv") > names(catches) [1] "ScientificName" "CommonName" "Lmax" "TL" "Habitat" "MeanCatch" > boxplot(catches$TL~catches$Habitat) TL = trophic level (position in the food web)

> boxplot(catches$Lmax~round(catches$TL,1),log="y", col="darkgreen", xlab="Trophic level", ylab="Maximum length (cm)") Round trophic levels to 1 decimal placeLog y-axis

Barplots Data should be a vector or a table Row names and column names are used by default > VADeaths Rural Male Rural Female Urban Male Urban Female

> barplot(VADeaths, legend=TRUE, ylab="Death rate") > barplot(VADeaths, legend=TRUE, ylab="Death rate", beside=TRUE)

barplot(t(VADeaths), legend=TRUE, ylab="Death rate", beside=TRUE, args.legend=list(x="topleft")) barplot(t(VADeaths), legend=TRUE, ylab="Death rate", beside=TRUE, args.legend=list(x="bottomright"), horiz=T)

Built-in iris dataset We want to compare sepal length, sepal width, petal length, and petal width in the iris data > iris Sepal.Length Sepal.Width Petal.Length Petal.Width Species setosa setosa setosa versicolor versicolor virginica virginica

In-class exercise 2a Create a two-panel plot using mfrow Panel 1 contains a boxplot comparing petal length among each of the three species in iris Panel 2 contains a boxplot comparing petal width among each of the three species in iris See next slide for plot you are aiming to produce (Done? Make the plot more beautiful!)

For all species combined... Now we want a boxplot comparing petal and sepal measurements for all species combined But the iris dataset is in the wrong format We want: > newiris measure data 1 Sepal.Length Sepal.Length Sepal.Width Sepal.Width Petal.Length Petal.Length Petal.Width Petal.Width 0.2

Hands-on exercise 2b Step 1: create a vector called measure, containing 150 copies of "Petal.Length", followed by 150 copies of "Sepal.Length", etc. Step 2: create a vector data containing the data in iris$Petal.Length, followed by the data in iris$Sepal.Length, etc. Step 3: create a data frame newiris using data.frame to combine measure and data Step 4: use boxplot to compare data as a function of measure in newiris (see next slide)