GG Plot Flashcards

Graphing data in R

1
Q

Components of a creating a plot using ggplot2

A
  1. Data (Vector or column)
  2. Aesthetic mappings of the data (x, y values, map variables to colors)
  3. At least one geometric object (type of plot or chart)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

inputs for Aesthetic Mappings

A

ggplot(data_frame, aes(x = x_column, y = y_column)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

inputs for geometric opject

A

geom_(point or histogram or box plot(plot inputs for bins, fill, etc)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Sample boxplot code

A

ggplot(family, aes( x = age, y = weight)) + geom_boxplot(color = ‘light blue’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Sample histogram code

A

ggplot(mpg, aes(x = engine size, y = ..density..##Fills density of 100)) + geom_histogram(bins = 5 ##of total bins, color = ‘blue’#color of bins)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

facet_wrap

A

Displays two histograms side by side by different variables:

ggplot(mpg, aes(x = engine size, y = ..density..##Fills density of 100)) + geom_histogram(bins = 5 ##of total bins, color = ‘blue’#color of bins) + facet_wrap(~vehicletype)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly