"It is not that I'm so smart. But I stay with the questions much longer."
― Albert Einstein
"It is not that I'm so smart. But I stay with the questions much longer."
― Albert Einstein
On a half-sheet of paper,
On the back of this sheet, answer the following questions:
Run the following first in your console to create the data example:
# Load packages library(dplyr) library(ggplot2) # Create data frame simple_ex <- data_frame( A = c(1, 2, 3, 4), B = c(1, 2, 3, 4), C = c(3, 2, 1, 2), D = c("a", "a", "b", "b") )
Let's view the data frame, which is in tidy format:
View(simple_ex)
A | B | C | D |
---|---|---|---|
1 | 1 | 3 | a |
2 | 2 | 2 | a |
3 | 3 | 1 | b |
4 | 4 | 2 | b |
mapping
of data
variables to aes()
thetic attributes of geom_
etric objects.point
s as the geom_
etric objectline
s as the geom_
etric objectgeom_
etric objects are point
sx
-axis is variable A
y
-axis is variable B
ggplot(data = simple_ex, mapping = aes(x = A, y = B)) + geom_point()
ggplot(data = simple_ex, mapping = aes(x = A, y = B)) + geom_point()
geom_
etric objects are point
sx
-axis is variable A
y
-axis is variable B
color
is variable D
ggplot(data = simple_ex, mapping = aes(x = A, y = B, color = D)) + geom_point()
ggplot(data = simple_ex, mapping = aes(x = A, y = B, color = D)) + geom_point()
geom_
etric objects are point
sx
-axis is variable A
y
-axis is variable B
size
is variable C
ggplot(data = simple_ex, mapping = aes(x = A, y = B, size = C)) + geom_point()
ggplot(data = simple_ex, mapping = aes(x = A, y = B, size = C)) + geom_point()
geom_
etric objects are line
sx
-axis is variable A
y
-axis is variable B
ggplot(data = simple_ex, mapping = aes(x = A, y = B)) + geom_line()
ggplot(data = simple_ex, mapping = aes(x = A, y = B)) + geom_line()
geom_
etric objects are line
sx
-axis is variable A
y
-axis is variable B
color
is variable D
ggplot(data = simple_ex, mapping = aes(x = A, y = B, color = D)) + geom_line()
ggplot(data = simple_ex, mapping = aes(x = A, y = B, color = D)) + geom_line()