Push the knit button!
library(tidyverse) # contains ggplot2, dplyr, tidyr, etc
library(palmerpenguins)
library(plotly)
library(GGally)
Make a scatterplot of flipper length by body_mass_g coloured by the three species of penguins. Add a tooltip that labels the points by variable values and the species.
p1 <- ggplot(penguins,
aes(x=flipper_length_mm,
y=body_mass_g,
colour=species)) +
geom_point()
ggplotly(p1, width=400, height=300)
Make a histogram of flipper_length_mm facetted by species and sex`, paying attention to remove the missing values. Add a tooltip that contains the count, flipper length of minimum of the bin.
p2 <- penguins %>%
filter(!is.na(sex)) %>%
ggplot(aes(x=flipper_length_mm)) +
geom_histogram(binwidth=5) +
facet_grid(sex~species)
ggplotly(p2, width=600, height=400)
Make a scatterplot matrix of four variables for the Gentoo penguins, coloured by sex. Pay attention to removing missing values.
gentoo <- penguins %>%
filter(species == "Gentoo") %>%
filter(!is.na(sex)) %>%
rename(bl = bill_length_mm,
bd = bill_depth_mm,
fl = flipper_length_mm,
bm = body_mass_g) %>%
select(bl, bd, fl, bm, sex)
gentoo_splom <- ggpairs(gentoo, columns=1:4,
aes(color = sex)) +
theme(axis.text = element_blank())
ggplotly(gentoo_splom, width=500, height=500) %>%
highlight(on="plotly_selected")
In preparation for lesson 3:
Sign up for an account on https://www.shinyapps.io
Authenticate your account
Install the library rsconnect (this is the part that may require admin access to your machine)