# A tibble: 10 × 5
name species hair_color skin_color eye_color
<chr> <chr> <chr> <chr> <chr>
1 Luke Skywalker Human blond fair blue
2 C-3PO Droid <NA> gold yellow
3 R2-D2 Droid <NA> white, blue red
4 Darth Vader Human none white yellow
5 Leia Organa Human brown light brown
6 Owen Lars Human brown, grey light blue
7 Beru Whitesun Lars Human brown light blue
8 R5-D4 Droid <NA> white, red red
9 Biggs Darklighter Human black light brown
10 Obi-Wan Kenobi Human auburn, white fair blue-gray
# A tibble: 10 × 4
name height species eye_color
<chr> <int> <chr> <chr>
1 Luke Skywalker 172 Human blue
2 Leia Organa 150 Human brown
3 Owen Lars 178 Human blue
4 Beru Whitesun Lars 165 Human blue
5 Biggs Darklighter 183 Human brown
6 Anakin Skywalker 188 Human blue
7 Wilhuff Tarkin 180 Human blue
8 Han Solo 180 Human brown
9 Boba Fett 183 Human brown
10 Lando Calrissian 177 Human brown
# A tibble: 10 × 4
name height mass species
<chr> <dbl> <dbl> <chr>
1 Luke Skywalker 1.72 77 Human
2 C-3PO 1.67 75 Droid
3 R2-D2 0.96 32 Droid
4 Darth Vader 2.02 136 Human
5 Leia Organa 1.5 49 Human
6 Owen Lars 1.78 120 Human
7 Beru Whitesun Lars 1.65 75 Human
8 R5-D4 0.97 32 Droid
9 Biggs Darklighter 1.83 84 Human
10 Obi-Wan Kenobi 1.82 77 Human
# A tibble: 10 × 5
name hair_color skin_color eye_color species
<chr> <chr> <chr> <chr> <chr>
1 Luke Skywalker blond fair blue Human
2 C-3PO <NA> gold yellow Robot
3 R2-D2 <NA> white, blue red Robot
4 Darth Vader none white yellow Human
5 Leia Organa brown light brown Human
6 Owen Lars brown, grey light blue Human
7 Beru Whitesun Lars brown light blue Human
8 R5-D4 <NA> white, red red Robot
9 Biggs Darklighter black light brown Human
10 Obi-Wan Kenobi auburn, white fair blue-gray Human
penguins %>%select(flipper_length_mm, body_mass_g, species) %>%ggplot(aes(flipper_length_mm, body_mass_g,color = species)) +geom_point(size =3,alpha =0.5) +labs(title ="Flipper Lingth vs Body Mass by Species",x ="Flipper Length (mm)",y ="Body Mass (g)" ) +theme_minimal()
Code
penguins %>%select(bill_length_mm, species) %>%ggplot(aes( bill_length_mm, species,fill = species)) +geom_boxplot()+coord_flip()+labs(title ="Bill Length Distribution by Species",x ="Species",y ="Bill Length (mm)" ) +theme_minimal()
Code
penguins %>%ggplot(aes(species, body_mass_g,fill = species)) +geom_bar(stat ="summary",fun ="mean",alpha =0.5) +labs(title ="Average Body Mass of Penguin Species",x ="Species",y ="Average Body Mass (g)" ) +theme_minimal()
Code
# Calculate overall mean weight for all chickensglobal_mean <-mean(chickwts$weight)# Summarize data to get median weight per feed typechickwts_summary <- chickwts %>%group_by(feed) %>%summarize(median_weight =median(weight)) %>%arrange(median_weight) # Sort by median for better visualization# Convert feed to factor for correct ordering in plotchickwts$feed <-factor(chickwts$feed, levels = chickwts_summary$feed)ggplot(chickwts, aes(x = weight, y = feed, color = feed)) +geom_vline(xintercept = global_mean, color ="black", linewidth =1, linetype ="dashed") +# Vertical line at global meangeom_point(alpha =0.6, size =2, position =position_jitter(width =0, height =0.2)) +# Jitter points for claritygeom_segment(data = chickwts_summary, aes(x = global_mean, xend = median_weight, y = feed, yend = feed, color = feed), linewidth =1) +# Lollipop sticks start at same global meangeom_point(data = chickwts_summary, aes(x = median_weight, y = feed, color = feed), size =4) +# Lollipop candy at median weighttheme_minimal() +labs(title ="Chicken Weight by Feed Type (Global Mean to Median Lollipop Plot)",x ="Weight (grams)",y ="Feed Type")
Code
library(ggridges)ggplot(lincoln_weather, aes(x =`Mean Temperature [F]`, y = Month, fill =stat(x))) +geom_density_ridges_gradient(scale =3, rel_min_height =0.01) +scale_fill_viridis_c(name ="Temp. [F]", option ="C") +labs(title ='Temperatures in Lincoln NE in 2016')
Warning: There was 1 warning in `mutate()`.
ℹ In argument: `marital = fct_relevel(...)`.
Caused by warning:
! 2 unknown levels in `f`: Never Married and No Answer
# A tibble: 6 × 2
marital n
<fct> <int>
1 Married 10117
2 Separated 743
3 Divorced 3383
4 No answer 17
5 Never married 5416
6 Widowed 1807
# A tibble: 10 × 2
name species
<chr> <chr>
1 Luke Skywalker HUMAN
2 C-3PO DROID
3 R2-D2 DROID
4 Darth Vader HUMAN
5 Leia Organa HUMAN
6 Owen Lars HUMAN
7 Beru Whitesun Lars HUMAN
8 R5-D4 DROID
9 Biggs Darklighter HUMAN
10 Obi-Wan Kenobi HUMAN