session ok

main
Gerardo Marx 1 month ago
parent 198cd51890
commit 65a6a1da6d

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

@ -3,18 +3,18 @@ library(palmerpenguins) # install.packages("palmerpenguins")
library(ggthemes)
penguins
view(penguins)
? penguins
# ggplot
ggplot(data = penguins,
mapping = aes(x=flipper_len, y=body_mass, colour = species)) +
mapping = aes(x=flipper_length_mm, y=body_mass_g, colour = species)) +
geom_point() +
geom_smooth(method = "lm")
# ggplot step 2:
ggplot(data = penguins,
mapping = aes(x=flipper_len, y=body_mass)) +
mapping = aes(x=flipper_length_mm, y=body_mass_g)) +
geom_point(mapping = aes(colour = species, shape = species)) +
geom_smooth(method = "lm")
@ -22,7 +22,7 @@ ggplot(data = penguins,
# ggplot final step:
ggplot(
data = penguins,
mapping = aes(x = flipper_len, y = body_mass)) +
mapping = aes(x = flipper_length_mm, y = body_mass_g)) +
geom_point(aes(color = species, shape = species), size = 3.5) +
geom_smooth(method = "lm") +
labs(
@ -50,5 +50,47 @@ ggplot(data = penguins,
ggplot(data = penguins,
mapping = aes(x = body_mass)) +
mapping = aes(x = body_mass_g)) +
geom_histogram(binwidth = 350)
ggplot(penguins, aes(x = body_mass_g)) +
geom_density()
# numerical and categorical
ggplot(penguins, aes(x = species, y = body_mass_g)) +
geom_boxplot()
# geom density
ggplot(penguins, aes(x = body_mass_g, color = species)) +
geom_density(linewidth = 0.75)
ggplot(penguins, aes(x = body_mass_g, color = species, fill = species)) +
geom_density(alpha = 0.5)
# 1.5.2 Two categorical variables
ggplot(penguins, aes(x = island, fill = species)) +
geom_bar()
ggplot(penguins, aes(x = island, fill = species)) +
geom_bar(position = "fill")
# Two numerical variables
ggplot(penguins, aes(x = flipper_length_mm, y = body_mass_g)) +
geom_point()
# Three or more variables
ggplot(penguins, aes(x = flipper_length_mm, y = body_mass_g)) +
geom_point(aes(color = species, shape = island), size=3.5)
ggplot(penguins, aes(x = flipper_length_mm, y = body_mass_g)) +
geom_point(aes(color = species, shape = species)) +
facet_wrap(~island)
ggplot(penguins, aes(x = flipper_length_mm, y = body_mass_g)) +
geom_point()
setwd("~/lwc/courses/data-science/data-visualization")
ggsave(filename = "penguin-plot.png")

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Loading…
Cancel
Save