Data Visualization Using R & ggplot2

Naupaka Zimmerman (@naupakaz) Andrew Tredennick (@ATredennick) Hat tip to Karthik Ram (@ inundata) for original slides August 10, 2014

Some housekeeping Install some packages install.packages("ggplot2", dependencies = TRUE) install.packages("plyr") install.packages("ggthemes") install.packages("reshape2") # for some of the examples towards the end: install.packages("gridExtra") install.packages("devtools") # Then a few packages to acquire data from the web to visualize install.packages("rfisheries") install.packages("rgbif") install.packages("taxize") # optional install_github("rWBclimate", "ropensci")

Section 1 Why ggplot2?

Why ggplot2?

I

More elegant & compact code than with base graphics

I

More aesthetically pleasing defaults than lattice

I

Very powerful for exploratory data analysis

Why ggplot2?

I

‘gg’ is for ‘grammar of graphics’ (term by Lee Wilkinson)

I

A set of terms that defines the basic components of a plot

I

Used to produce figures using coherant, consistant syntax

Why ggplot2?

I

Supports a continuum of expertise:

I

Easy to get started, plenty of power for complex figures

Section 2 The Grammar

Some terminology

I

data

I

Must be a data.frame

I

Gets pulled into the ggplot() object

The iris dataset

head(iris) ## ## ## ## ## ## ##

1 2 3 4 5 6

Sepal.Length Sepal.Width Petal.Length Petal.Width Species 5.1 3.5 1.4 .2 setosa 4.9 3. 1.4 .2 setosa 4.7 3.2 1.3 .2 setosa 4.6 3.1 1.5 .2 setosa 5. 3.6 1.4 .2 setosa 5.4 3.9 1.7 .4 setosa

plyr and reshape are key for using R

These two packages are the swiss army knives of R. I plyr 1. ddply (data frame to data frame ply) 1.1 split 1.2 apply 1.3 combine

2. llply (list to list ply) 3. join

plyr iris[1:2, ] ## Sepal.Length Sepal.Width Petal.Length Petal.Width Species ## 1 5.1 3.5 1.4 .2 setosa ## 2 4.9 3. 1.4 .2 setosa # Note the use of the . function to allow Species to be used # without quoting ddply(iris, .(Species), summarize, mean.Sep.Wid = mean(Sepal.Width, na.rm = TRUE)) ## Species mean.Sep.Wid ## 1 setosa 3.428 ## 2 versicolor 2.77 ## 3 virginica 2.974

plyr and reshape are key for using R

These two packages are the swiss army knives of R. I reshape 1. melt 2. dcast (data frame output) 3. acast (vector/matrix/array output)

reshape2

iris[1:2, ] ## Sepal.Length Sepal.Width Petal.Length Petal.Width Species ## 1 5.1 3.5 1.4 .2 setosa ## 2 4.9 3. 1.4 .2 setosa df <- melt(iris, id.vars = "Species") df[1:2, ] ## Species variable value ## 1 setosa Sepal.Length 5.1 ## 2 setosa Sepal.Length 4.9

reshape2 df[1:2, ] ## Species variable value ## 1 setosa Sepal.Length 5.1 ## 2 setosa Sepal.Length 4.9 dcast(df, Species ˜ variable, mean) ## ## ## ## ## ## ## ##

Species Sepal.Length Sepal.Width Petal.Length 1 setosa 5. 6 3.428 1.462 2 versicolor 5.936 2.77 4.26 3 virginica 6.588 2.974 5.552 Petal.Width 1 .246 2 1.326 3 2. 26

Section 3 Aesthetics

Some terminology

I

data

I

aesthetics

I

How your data are represented visually I

a.k.a. mapping

I

which data on the x

I

which data on the y

I

but also: color,

size, shape, transparency

Let’s try an example

myplot <- ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width)) summary(myplot) ## data: Sepal.Length, Sepal.Width, Petal.Length, ## Petal.Width, Species [15 x5] ## mapping: x = Sepal.Length, y = Sepal.Width ## faceting: facet_null()

Section 4 Geoms

Some terminology

I

data

I

The geometric objects in the plot

I

aesthetics

I

points, lines, polygons, etc

I

geometry

I

shortcut functions: geom point(), geom bar(), geom line()

Basic structure

ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point() myplot <- ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width)) myplot + geom_point() I

Specify the data and variables inside the ggplot function.

I

Anything else that goes in here becomes a global setting.

I

Then add layers: geometric objects, statistical models, and facets.

Quick note

I

Never use qplot - short for quick plot.

I

You‘ll end up unlearning and relearning a good bit.

Let’s try an example ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point() 4.5 ● ● ●

4.0

● ● ●





Sepal.Width

● ●

● ● ●

● ●



● ●

● ● ●

● ● ●

3.0

● ●





● ●

● ●

● ● ●

● ● ●

● ●













● ●



● ● ●

● ● ● ● ●

● ●





● ● ● ●

● ● ● ● ●

● ● ●







● ● ●



● ● ●





● ●



● ●

2.0

● ● ●



● ● ●



● ● ●

● ●



2.5





● ● ● ●



● ●

● ●

3.5





5

6

Sepal.Length

7

8

Changing the aesthetics of a geom: Increase the size of points ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width)) + geom_point(size = 3) 4.5

● ● ● ●

4.0



Sepal.Width

● ●





●● ●●● ● ● ●●● ●● ●● ● ● ●● ●●●

3.5 ●

3.0

●● ●

● ● ●

2.5 ●

2.0

● ●



●●



● ● ●



●● ●

● ●● ●●● ● ● ● ● ● ●● ●●● ●●●● ●● ●● ●●●●● ● ● ●●● ●●●●● ● ● ● ● ● ●● ● ●● ● ●●● ● ● ● ● ● ● ● ●

●● ● ●



5

6

Sepal.Length

7

8

Changing the aesthetics of a geom: Add some color ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point(size = 3) 4.5

● ● ● ●

Sepal.Width

4.0

● ● ● ●●



● ●



3.5

3.0

2.5

2.0

●● ● ●●● ● ● ● ●●● ● ● ●● ●● ● ● ● ●● ● ● ●● ●●● ● ● ●● ● ● ● ●● ●●● ● ●● ●●● ●●●● ●● ●● ● ●● ●●●●● ● ● ●●● ●●●●● ● ● ● ● ● ● ● ●● ● ●● ● ● ● ● ●●● ● ● ● ● ● ● ● ● ● ●

Species ● setosa ● versicolor ● virginica



5

6

Sepal.Length

7

8

Changing the aesthetics of a geom: Di↵erentiate points by shape ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point(aes(shape = Species), size = 3) # Why aes(shape = Species)? 4.5

● ●

Sepal.Width

4.0

3.5

3.0

● ● ● ●●



● ● ●

●● ●●● ● ● ● ●●● ● ●● ● ●● ● ● ●● ●● ●●● ●

Species ● setosa

versicolor virginica

2.5 ●

2.0 5

6

Sepal.Length

7

8

Exercise 1 # Make a small sample of the diamonds dataset d2 <- diamonds[sample(1:dim(diamonds)[1], 1 ), ]

Then generate this plot below. ●

● ● ●● ● ●

15000

● ● ● ● ● ● ●● ● ●●



● ●

● ●● ● ● ●● ●●● ● ● ● ●● ● ● ● ● ● ● ● ● ● ●● ● ●● ● ● ●● ● ● ●● ● ● ● ● ● ● ● ● ●● ● ● ●● ● ●● ● ● ● ●● ● ● ● ●● ● ●●● ● ●●●● ●● ● ● ●● ● ● ● ● ● ● ● ●●● ● ● ● ●● ● ●● ●● ●● ● ● ● ●●● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●●● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ●● ● ●● ● ● ●● ● ● ● ● ● ● ● ● ●● ● ● ● ●●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ●● ● ● ●● ●● ● ●●● ● ● ●● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ●●● ● ● ●● ● ● ● ● ●● ● ● ● ● ●● ● ● ● ● ● ●●● ● ● ● ● ● ● ● ●● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ●● ● ● ● ● ● ● ●● ● ● ● ●● ● ● ● ● ● ● ● ● ● ●●● ● ● ● ●● ● ●● ● ● ●● ● ● ● ● ●● ● ● ● ● ● ● ● ●●● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●●● ● ●● ●● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●●





price



10000

5000

0

1

● ● ● ● ● ● ●● ● ● ● ● ●









color

● ● ● ● ● ● ● ● ●● ● ●● ●



D



E



F



G



H



I



J



2

carat

● ● ●

3

Section 5 Stats

Some terminology

I

data

I

aesthetics

I

geometry

I

stats

I

Statistical transformations and data summary

I

All geoms have associated default stats, and vice versa

I

e.g. binning for a histogram or fitting a linear model

Built-in stat example: Boxplots See ?geom boxplot for list of options library(MASS) ggplot(birthwt, aes(factor(race), bwt)) + geom_boxplot()

5000

bwt

4000

3000

2000



1000



1

2

factor(race)

3

Built-in stat example: Boxplots

myplot <- ggplot(birthwt, aes(factor(race), bwt)) + geom_boxplot() summary(myplot) ## ## ## ## ## ## ## ##

data: low, age, lwt, race, smoke, ptl, ht, ui, ftv, bwt [189x1 ] mapping: x = factor(race), y = bwt faceting: facet_null() ----------------------------------geom_boxplot: outlier.colour = black, outlier.shape = 16, outlier.size = stat_boxplot: position_dodge: (width = NULL, height = NULL)

Section 6 Facets

Some terminology

I

data

I

Subsetting data to make lattice plots

I

aesthetics

I

Really powerful

I

geometry

I

stats

I

facets

Faceting: single column, multiple rows

● ● ● ● ● ● ● ●● ● ● ●● ●● ●●● ●● ● ●● ●● ●●●●● ●● ●● ● ●●● ●

Species versicolor

● ● ●● ● ●● ●● ●● ● ●●● ●● ● ● ●● ● ●●● ● ●● ● ● ●●●● ● ●●● ● ● ● ●● ● ●● ● ●● ●●● ●●● ● ●●● ●● ●● ●●● ●●● ● ● ●● ● ●● ● ● ●● ● ● ● ●● ● ●



5

6

7

Sepal.Length

8

virginica

4.5 4.0 3.5 3.0 2.5 2.0 4.5 4.0 3.5 3.0 2.5 2.0 4.5 4.0 3.5 3.0 2.5 2.0

setosa

Sepal.Width

ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point() + facet_grid(Species ˜ .)



setosa



versicolor



virginica

Faceting: single row, multiple columns ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point() + facet_grid(. ˜ Species)

setosa

4.5

Sepal.Width

4.0 3.5 3.0

● ● ● ● ●● ●● ● ●● ● ● ● ●● ●● ●● ● ●● ● ● ●● ●● ●● ● ● ●● ● ● ●

2.5 ●

2.0

versicolor virginica



●● ● ● ● ●● ● ●● ●● ●●● ● ● ● ●● ● ●●● ●●●● ●●●● ●● ● ●● ● ● ●● ●● ● ●●

● ● ●● ● ●● ●● ●●● ● ● ●●● ●● ●● ● ● ● ●●● ● ● ●● ●● ● ● ● ● ● ●● ●



5 6 7 8 5 6 7 8 5 6 7 8

Sepal.Length

Species ●

setosa



versicolor



virginica

or just wrap your facets ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point() + facet_wrap( ˜ Species) # notice lack of .

setosa

4.5

Sepal.Width

4.0 3.5 3.0

● ● ● ● ●● ●● ● ●● ● ● ● ●● ●● ●● ● ●● ● ● ●● ●● ●● ● ● ●● ● ● ●

2.5 ●

2.0

versicolor virginica



●● ● ● ● ●● ● ●● ●● ●●● ● ● ● ●● ● ●●● ●●●● ●●●● ●● ● ●● ● ● ●● ●● ● ●●

● ● ●● ● ●● ●● ●●● ● ● ●●● ●● ●● ● ● ● ●●● ● ● ●● ●● ● ● ● ● ● ●● ●



5 6 7 8 5 6 7 8 5 6 7 8

Sepal.Length

Species ●

setosa



versicolor



virginica

Section 7 Scales

Some terminology

I

data

I

aesthetics

I

geometry

I

stats

I

facets

I

scales

I

Control the mapping from data to aesthetics

I

Often used for adjusting color mapping

Colors

aes(color = variable) # mapping color = "black" # setting # Or add it as a scale scale_fill_manual(values = c("color1", "color2"))

The RColorBrewer package library(RColorBrewer) display.brewer.all()

Using a color brewer palette df <- melt(iris, id.vars = "Species") ggplot(df, aes(Species, value, fill = variable)) + geom_bar(stat = "identity", position = "dodge") + scale_fill_brewer(palette = "Set1")

8

6 variable

value

Sepal.Length Sepal.Width

4

Petal.Length Petal.Width 2

0 setosa

versicolor

Species

virginica

Manual color scale

● ● ● ● ● ●● ● ● ● ●● ●● ● ● ● ●●● ●● ●● ● ●● ●●●●● ●● ● ●●● ●

Species versicolor

● ● ●● ● ●● ●● ●● ● ●●● ●● ●●● ●●● ● ● ●●● ●● ●● ● ● ● ● ●● ● ● ● ●● ● ●● ● ●● ●●● ●●● ● ●●● ●● ●● ●●● ●●● ● ●● ● ●● ● ●● ●● ● ● ● ●● ● ●



5

6

7

Sepal.Length

8

virginica

4.5 4.0 3.5 3.0 2.5 2.0 4.5 4.0 3.5 3.0 2.5 2.0 4.5 4.0 3.5 3.0 2.5 2.0

setosa

Sepal.Width

ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point() + facet_grid(Species ˜ .) + scale_color_manual(values = c("red", "green", "blue"))



setosa



versicolor



virginica

Refer to a color chart for beautful visualizations

http://tools.medialab.sciences-po.fr/iwanthue/

Adding a continuous scale to an axis library(MASS) ggplot(birthwt, aes(factor(race), bwt)) + geom_boxplot(width = .2) + scale_y_continuous(labels = (paste (1:4, " Kg")), breaks = seq(1 , 4 , by = 1 ))

bwt

4 Kg

3 Kg

2 Kg



1 Kg



1

2

factor(race)

3

Commonly used scales

scale_fill_discrete(); scale_colour_discrete() scale_fill_hue(); scale_color_hue() scale_fill_manual(); scale_color_manual() scale_fill_brewer(); scale_color_brewer() scale_linetype(); scale_shape_manual()

Section 8 Coordinates

Some terminology

I

data

I

Not going to cover this in detail

I

aesthetics

I

e.g. polar coordinate plots

I

geometry

I

stats

I

facets

I

scales

I

coordinates

Section 9 Putting it all together with more examples

Section 10 Histograms

See ?geom histogram for list of options h <- ggplot(faithful, aes(x = waiting)) h + geom_histogram(binwidth = 3 , colour = "black")

count

150

100

50

0 0

50

100

waiting

150

h <- ggplot(faithful, aes(x = waiting)) h + geom_histogram(binwidth = 8, fill = "steelblue", colour = "black")

count

60

40

20

0 30

50

70

waiting

90

Section 11 Line plots

climate <- read.csv("../data/climate.csv", header = T) ggplot(climate, aes(Year, Anomaly1 y)) + geom_line()

Anomaly10y

0.5

0.0

1920

1950

1980

Year

climate <- read.csv(text = RCurl::getURL(https://raw.github.com/karthikram/ggplot-lecture/master/climate.csv))

We can also plot confidence regions ggplot(climate, aes(Year, Anomaly1 y)) + geom_ribbon(aes(ymin = Anomaly1 y - Unc1 y, ymax = Anomaly1 y + Unc1 y), fill = "blue", alpha = .1) + geom_line(color = "steelblue")

Anomaly10y

0.5

0.0

1920

1950

Year

1980

Exercise 2 Modify the previous plot and change it such that there are three lines instead of one with a confidence band.

0.5

Anomaly10y

I

0.0

1920

1950

Year

1980

Section 12 Bar plots

ggplot(iris, aes(Species, Sepal.Length)) + geom_bar(stat = "identity")

Sepal.Length

300

200

100

0 setosa

versicolor

Species

virginica

df <- melt(iris, id.vars = "Species") ggplot(df, aes(Species, value, fill = variable)) + geom_bar(stat = "identity")

750

value

variable Sepal.Length

500

Sepal.Width Petal.Length Petal.Width 250

0 setosa

versicolor

Species

virginica

ggplot(df, aes(Species, value, fill = variable)) + geom_bar(stat = "identity", position = "dodge")

8

6 variable

value

Sepal.Length Sepal.Width

4

Petal.Length Petal.Width 2

0 setosa

versicolor

Species

What’s going on with the y axis?

virginica

ggplot(df, aes(Species, value, fill = variable)) + geom_bar(stat = "identity", position="dodge", color="black")

8

6 variable

value

Sepal.Length Sepal.Width

4

Petal.Length Petal.Width 2

0 setosa

versicolor

Species

virginica

Exercise 3 Using the d2 dataset you created earlier, generate this plot below. Take a quick look at the data first to see if it needs to be binned. 100

cut

75

count

Fair Good Very Good

50

Premium Ideal 25

0 I1

SI2

SI1

VS2

VS1

clarity

VVS2 VVS1

IF

Exercise 4 I

Using the climate dataset, create a new variable called sign. Make it logical (true/false) based on the sign of Anomaly10y.

I

Plot a bar plot and use sign variable as the fill.

Anomaly10y

0.5 sign FALSE TRUE 0.0

1920

1950

Year

1980

Section 13 Density Plots

Density plots ggplot(faithful, aes(waiting)) + geom_density()

density

0.03

0.02

0.01

0.00 50

60

70

waiting

80

90

Density plots ggplot(faithful, aes(waiting)) + geom_density(fill = "blue", alpha =

.1)

density

0.03

0.02

0.01

0.00 50

60

70

waiting

80

90

ggplot(faithful, aes(waiting)) + geom_line(stat = "density")

density

0.03

0.02

0.01

50

60

70

waiting

80

90

Section 14 Adding smoothers

ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point(aes(shape = Species), size = 3) + geom_smooth(method = "lm") 4.5

● ● ●

Sepal.Width

4.0

3.5

3.0

● ● ● ● ● ●● ● ●● ●●● ● ● ● ●●● ● ●● ● ●● ● ● ●● ●● ●●● ●

Species ● setosa

versicolor virginica

2.5 ●

2.0 5

6

Sepal.Length

7

8

ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point(aes(shape = Species), size = 3) + geom_smooth(method = "lm") + facet_grid(. ˜ Species) setosa

4.5

versicolor

virginica

● ●

Sepal.Width

4.0

3.5

3.0

● ● ● ● ● ●●● ● ●● ●●● ● ●●●●●● ●● ●●● ● ●●● ●● ●●● ●

Species ● setosa

versicolor virginica

2.5 ●

2.0 5

6

7

8

5

6

7

Sepal.Length

8

5

6

7

8

Section 15 Themes

Adding themes

Themes are a great way to define custom plots. + theme() # see ?theme() for more options

A more basic theme ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point(size = 1.2, shape = 16) + facet_wrap( ˜ Species) + theme_bw() setosa

4.5

versicolor

virginica



● ●

4.0

● ● ●



● ●

Sepal.Width

● ●● ●

●●

3.5

●●●



● ● ●●● ●



●● ● ●●

●● ●











● ●●

3.0

●●

Species



●●

● ●

●●●

● ●● ● ●



●● ● ●



●●

●●●

●●● ● ● ●



● ● ●



● ● ●

● ●●

● ●

●●●



●●

●●







● ●



● ●



● ●



5

6

7

8

5

6

7

Sepal.Length

8

5

6

setosa



versicolor



virginica

●●

● ●

● ●



●●

● ●

2.0

●● ● ●

● ●

● ●●

2.5



7

8

A themed plot

ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point(size = 1.2, shape = 16) + facet_wrap( ˜ Species) + theme(legend.key = element_rect(fill = NA), legend.position = "bottom", strip.background = element_rect(fill = NA), axis.title.y = element_text(angle = ))

A themed plot

setosa

4.5

versicolor

virginica

● ●

4.0 3.5

Sepal.Width

3.0

● ● ● ● ● ●●● ● ●● ●●● ● ●●●●●● ●● ●●● ● ●●● ●● ●●● ●

●● ● ● ● ● ● ● ●● ●●●●● ●● ●● ●●●●● ● ● ●● ● ●●● ● ●●● ● ●● ● ● ● ● ● ● ●●

2.5 ●

2.0



●● ● ● ●● ●● ● ● ●● ● ●●● ●●● ●● ●● ● ● ●● ●●● ●● ● ●● ● ● ● ● ● ●



5 6 7 8

5 6 7 8

5 6 7 8

Sepal.Length Species



setosa



versicolor



virginica

ggthemes library

install.packages(ggthemes) library(ggthemes) # Then add one of these themes to your plot + theme_stata() + theme_excel() + theme_wsj() + theme_solarized()

Fan of Wes Anderson movies?

Yup, that’s a thing # install.packages(wesanderson) library("wesanderson") # display a palette display.wes.palette(4, "Royal1")

Royal1

Section 16 Create functions to automate your plotting

Write functions for day to day plots

my_custom_plot <- function(df, title = "", ...) { ggplot(df, ...) + ggtitle(title) + whatever_geoms() + theme(...) }

Then just call your function to generate a plot. It’s a lot easier to fix one function that do it over and over for many plots plot1 <- my_custom_plot(dataset1, title = "Figure 1")

Section 17 Publication quality figures

I

If the plot is on your screen ggsave(˜/path/to/figure/filename.png)

I

If your plot is assigned to an object ggsave(plot1, file = "˜/path/to/figure/filename.png")

I

Specify a size ggsave(file = "/path/to/figure/filename.png", width = 6, height =4)

I

or any format (pdf, png, eps, svg, jpg) ggsave(file = "/path/to/figure/filename.eps") ggsave(file = "/path/to/figure/filename.jpg") ggsave(file = "/path/to/figure/filename.pdf")

Further help I

You’ve just scratched the surface with ggplot2.

I

Practice

I

Read the docs (either locally in R or at http://docs.ggplot2.org/current/)

I

Work together

visualization with ggplot and R - GitHub Pages

Aug 10, 2014 - Some terminology. ▷ data. ▷ aesthetics. ▷ geometry. ▷ The geometric objects in the plot. ▷ points, lines, polygons, etc. ▷ shortcut functions: geom point(), geom bar(), geom line(). Page 20. Basic structure ggplot(data = iris ...... Page 55. Section 12. Bar plots. Page 56. ggplot(iris, aes(Species, Sepal.

3MB Sizes 0 Downloads 254 Views

Recommend Documents

Data Visualization Using R & ggplot2 - GitHub Pages
Feb 22, 2015 - 3. 1.4 .2 setosa. # Note the use of the . function to allow Species to be used ..... Themes are a great way to define custom plots. ... Then just call your function to generate a plot. ... ggsave(file = "/path/to/figure/filename.pdf") 

Elastic computing with R and Redis - GitHub
May 16, 2016 - Listing 3 presents a parallel-capable variation of the boot function from the ... thisCall

Getting Acquainted with R - GitHub
In this case help.search(log) returns all the functions with the string 'log' in them. ... R environment your 'working directory' (i.e. the directory on your computer's file ... Later in the course we'll discuss some ways of implementing sanity check

r - GitHub
Page 1. § *>-. -J o. N. I ft. 3. J£> O. 0. & v. /. II. -5> O o I. 3 n. \. ) -9-. )t -0. °. I o o I tl. J. > •tl. O. 0 f- H' a. II I) in r. 4. , .«- ^ u. +. 5. #^. N. Page 2. co. 2.5". C2-) m. V. C*.

Financial Risk Modelling and Portfolio Optimization with R - GitHub
website of the R project is http://www.r-project.org. The source code of the software is published as free software under the terms of the GNU General Public ..... Eclipse Eclipse is a Java-based IDE and was first designed as an IDE for this ...... â

International Marketing by Philip R. Cateora, Mary C ... - GitHub Pages
The benefit you get by reading this book is actually information inside this reserve incredible fresh ... you can have it inside your lovely laptop even cell phone.

International Marketing by Philip R. Cateora, Mary C ... - GitHub Pages
The benefit you get by reading this book is actually information inside this reserve incredible fresh ... you can have it inside your lovely laptop even cell phone.

yashraj r. sontakke - GitHub
Aug'10 -‐ May'12 ... Aug'06 -‐ May'10 ... Calculator Application for Android Smartphone. Fall'10. • The App includes basic calculations with some advanced ...

Introduction to R - GitHub
Nov 30, 2015 - 6 Next steps ... equals, ==, for equality comparison. .... invoked with some number of positional arguments, which are always given, plus some ...

R Graphics Output - GitHub
Why did I color them blue and red? Petal.Width. P etal.Length ... This blue sliver is the covariance. ...... is the ratio of the small rectangle to the big rectangle.

R Graphics Output - GitHub
0.3. 0.4. 0.5. R2Y. Q2Y. −0.15. −0.05 0.00. 0.05. 0.10. 0.15. −0.1. 0.0. 0.1. 0.2. Loadings p1 (22%). pOrtho1 (22%). M201.8017T217. M239.0705T263. M241.0881T263. M212.1367T256. M212.0743T273. M207.9308T206. M235.0975T362. M236.1009T363. M221.08

R Graphics Output - GitHub
0.5. 1.0. Features for level high versus low relative covariance(feature,t1) correlation(feature. ,t1) high low. M201.8017T217. M201.8017T476. M203.7987T252. M203.7988T212. M205.8387T276. M205.8398T264. M205.839T273. M207.9308T206. M207.9308T302. M21

R Graphics Output - GitHub
1.0. 1.5. −1.0. −0.5. 0.0. 0.5. 1.0. Significant features for level k3 versus other relative covariance(feature,t1) correlation(feature. ,t1) k3 other. M201.8017T217. M201.8017T476. M205.8387T251. M205.8398T264. M207.9308T206. M207.9308T311. M212

Jason R. Parham - GitHub
Education. Rensselaer Polytechnic Institute. Troy, NY. D. P Y · C S · C V. Aug ... Master's Thesis: “Photographic Censusing of Zebra and Girafe in the Nairobi ...

D A. R - GitHub
policy, and “big data” issues in the geosciences including the design and construction ... novel applications of machine learning and data science to the analysis .... Aerosol-Cloud-Climate Interactions. Seattle, WA. 2017. |. PDF. Rothenberg,D.

R Graphics Output - GitHub
Page 1. 0.00. 0.25. 0.50. 0.75. 1.00. Den−Dist−Pop. Index. Density−Distance−Population Index. By County, Compared to Median.

Jason R. Parham - GitHub
2-101 Waters View Cr, Cohoes, NY 12047. (714) 814-5305 | [email protected] .... PHP / HTML / CSS / MySQL. JavaScript / jQuery / AJAX . /S Y/S Y. Sep.

r krishna - GitHub
Validating Industrial Text Mining. Sept 2015 - May 2017. Industrial collaboration with LexisNexis. Raleigh, NC. ◦ Worked on validating large scale natural language processing pipelines for technology assisted review at LexisNexis. ◦ Demonstrated

R Graphics Output - GitHub
1816 − Monroe. 1820 − Monroe. 1824 − Adams. 1828 − Jackson. 1832 − Jackson. 1836 − V an Buren. 1840 − Harrison. 1844 − P olk. 1848 − T a ylor. 1852 − ...

A tutorial on clonal ordering and visualization using ClonEvol - GitHub
Aug 18, 2017 - It uses the clustering of heterozygous variants identified using other tools as input to infer consensus clonal evolution trees and estimate the cancer cell ... This results in a bootstrap estimate of the sampling distribution of the C

R Markdown : : CHEAT SHEET - GitHub
Word, or RTF documents; html or pdf based slides ... stop render when errors occur (FALSE) (default = FALSE) .... colortheme. Beamer color theme to use. X css.