ggplot2The objective of this assignment is to complete and explain basic plots before moving on to more complicated ways to graph data.
Each question is worth 5 points.
To submit this homework you will create the document in Rstudio,
using the knitr package (button included in Rstudio) and then submit the
document to your Rpubs account. Once
uploaded you will submit the link to that document on Canvas. Please
make sure that this link is hyper linked and that I can see the
visualization and the code required to create it
(echo=TRUE).
mosaicData package.data("Marriage")
Marriage
## bookpageID appdate ceremonydate delay officialTitle person dob
## 1 B230p539 1996-10-29 1996-11-09 11 CIRCUIT JUDGE Groom 1964-04-11
## 2 B230p677 1996-11-12 1996-11-12 0 MARRIAGE OFFICIAL Groom 1964-08-06
## 3 B230p766 1996-11-19 1996-11-27 8 MARRIAGE OFFICIAL Groom 1962-02-20
## 4 B230p892 1996-12-02 1996-12-07 5 MINISTER Groom 1956-05-20
## 5 B230p994 1996-12-09 1996-12-14 5 MINISTER Groom 1966-12-14
## 6 B230p1209 1996-12-26 1996-12-26 0 MARRIAGE OFFICIAL Groom 1970-02-21
## 7 B230p1354 1997-01-08 1997-01-24 16 MARRIAGE OFFICIAL Groom 1971-10-11
## 8 B230p1665 1997-02-10 1997-02-10 0 MARRIAGE OFFICIAL Groom 1962-01-31
## 9 B230p1948 1997-03-03 1997-03-31 28 MARRIAGE OFFICIAL Groom 1975-12-04
## 10 B231p48 1997-03-12 1997-03-22 10 MINISTER Groom 1951-07-02
## 11 B231p198 1997-03-21 1997-03-29 8 PASTOR Groom 1955-02-06
## 12 B231p406 1997-04-07 1997-04-07 0 CHIEF CLERK Groom 1967-11-15
## 13 B231p632 1997-04-22 1997-04-26 4 MARRIAGE OFFICIAL Groom 1976-09-01
## 14 B231p713 1997-04-30 1997-05-04 4 MINISTER Groom 1978-10-15
## 15 B231p1042 1997-05-23 1997-05-23 0 MARRIAGE OFFICIAL Groom 1954-10-30
## 16 B231p1201 1997-06-03 1997-06-07 4 PASTOR Groom 1959-11-28
## 17 B231p1436 1997-06-18 1997-06-27 9 PASTOR Groom 1966-01-30
## 18 B231p1841 1997-07-14 1997-07-14 0 MARRIAGE OFFICIAL Groom 1978-05-19
## 19 B232p148 1997-08-07 1997-08-10 3 REVEREND Groom 1943-02-20
## 20 B232p299 1997-08-18 1997-08-30 12 PASTOR Groom 1948-05-19
## 21 B232p522 1997-09-04 1997-09-06 2 PASTOR Groom 1945-04-10
## 22 B232p770 1997-09-24 1997-09-26 2 MINISTER Groom 1952-11-29
## 23 B232p1079 1997-10-20 1997-10-20 0 MARRIAGE OFFICIAL Groom 1958-10-20
## 24 B232p1211 1997-10-31 1997-10-31 0 MARRIAGE OFFICIAL Groom 1960-01-06
## 25 B232p1519 1997-11-26 1997-11-26 0 MARRIAGE OFFICIAL Groom 1972-11-27
## 26 B232p1888 1997-12-31 1997-12-31 0 MARRIAGE OFFICIAL Groom 1971-08-06
## 27 B233p141 1998-01-30 1998-01-30 0 MARRIAGE OFFICIAL Groom 1978-10-21
## 28 B233p268 1998-02-12 1998-02-14 2 ELDER Groom 1979-10-10
## 29 B233p429 1998-02-27 1998-03-07 8 PASTOR Groom 1957-04-06
## 30 B233p674 1998-03-13 1998-04-04 22 CATHOLIC PRIEST Groom 1971-03-03
## 31 B233p903 1998-03-31 1998-03-31 0 MARRIAGE OFFICIAL Groom 1978-02-25
## 32 B233p1245 1998-04-23 1998-04-24 1 PASTOR Groom 1946-09-19
## 33 B233p1381 1998-05-01 1998-05-23 22 PASTOR Groom 1975-04-18
## 34 B233p1690 1998-05-26 1998-05-30 4 MINISTER Groom 1964-06-05
## 35 B233p1899 1998-06-09 1998-06-27 18 MARRIAGE OFFICIAL Groom 1975-02-13
## 36 B234p65 1998-06-18 1998-06-20 2 BISHOP Groom 1956-11-26
## 37 B234p438 1998-07-13 1998-08-01 19 PASTOR Groom 1924-05-21
## 38 B234p687 1998-07-31 1998-07-31 0 MARRIAGE OFFICIAL Groom 1927-03-18
## 39 B234p904 1998-08-13 1998-08-13 0 MARRIAGE OFFICIAL Groom 1941-05-28
## 40 B234p1292 1998-09-15 1998-09-26 11 PASTOR Groom 1969-09-20
## 41 B234p1485 1998-10-02 1998-10-02 0 MARRIAGE OFFICIAL Groom 1943-02-26
## 42 B234p1621 1998-10-14 1998-10-23 9 MINISTER Groom 1980-03-07
## 43 B234p1966 1998-11-09 1998-11-09 0 MARRIAGE OFFICIAL Groom 1980-05-28
## 44 B235p7 1998-11-12 1998-11-28 16 MINISTER Groom 1978-09-14
## 45 B235p259 1998-12-02 1998-12-05 3 PASTOR Groom 1955-02-18
## 46 B235p404 1998-12-14 1998-12-14 0 MARRIAGE OFFICIAL Groom 1960-09-20
## 47 B235p563 1998-12-23 1998-12-23 0 MARRIAGE OFFICIAL Groom 1974-05-20
## 48 B235p837 1999-01-22 1999-01-31 9 MINISTER Groom 1931-07-19
## 49 B235p992 1999-02-05 1999-02-06 1 MINISTER Groom 1959-12-20
## 50 B230p539 1996-10-29 1996-11-09 11 CIRCUIT JUDGE Bride 1968-02-25
## 51 B230p677 1996-11-12 1996-11-12 0 MARRIAGE OFFICIAL Bride 1944-04-24
## 52 B230p766 1996-11-19 1996-11-27 8 MARRIAGE OFFICIAL Bride 1970-03-10
## 53 B230p892 1996-12-02 1996-12-07 5 MINISTER Bride 1957-05-18
## 54 B230p994 1996-12-09 1996-12-14 5 MINISTER Bride 1972-12-23
## 55 B230p1209 1996-12-26 1996-12-26 0 MARRIAGE OFFICIAL Bride 1971-11-19
## 56 B230p1354 1997-01-08 1997-01-24 16 MARRIAGE OFFICIAL Bride 1971-12-08
## 57 B230p1665 1997-02-10 1997-02-10 0 MARRIAGE OFFICIAL Bride 1976-09-05
## 58 B230p1948 1997-03-03 1997-03-31 28 MARRIAGE OFFICIAL Bride 1977-03-20
## 59 B231p48 1997-03-12 1997-03-22 10 MINISTER Bride 1953-07-22
## 60 B231p198 1997-03-21 1997-03-29 8 PASTOR Bride 1963-04-13
## 61 B231p406 1997-04-07 1997-04-07 0 CHIEF CLERK Bride 1973-04-26
## 62 B231p632 1997-04-22 1997-04-26 4 MARRIAGE OFFICIAL Bride 1980-04-23
## 63 B231p713 1997-04-30 1997-05-04 4 MINISTER Bride 1977-02-01
## 64 B231p1042 1997-05-23 1997-05-23 0 MARRIAGE OFFICIAL Bride 1959-06-25
## 65 B231p1201 1997-06-03 1997-06-07 4 PASTOR Bride 1958-03-02
## 66 B231p1436 1997-06-18 1997-06-27 9 PASTOR Bride 1976-04-14
## 67 B231p1841 1997-07-14 1997-07-14 0 MARRIAGE OFFICIAL Bride 1978-04-17
## 68 B232p148 1997-08-07 1997-08-10 3 REVEREND Bride 1947-11-16
## 69 B232p299 1997-08-18 1997-08-30 12 PASTOR Bride 1953-06-23
## 70 B232p522 1997-09-04 1997-09-06 2 PASTOR Bride 1954-09-10
## 71 B232p770 1997-09-24 1997-09-26 2 MINISTER Bride 1952-10-01
## 72 B232p1079 1997-10-20 1997-10-20 0 MARRIAGE OFFICIAL Bride 1970-05-21
## 73 B232p1211 1997-10-31 1997-10-31 0 MARRIAGE OFFICIAL Bride 1959-03-29
## 74 B232p1519 1997-11-26 1997-11-26 0 MARRIAGE OFFICIAL Bride 1977-02-21
## 75 B232p1888 1997-12-31 1997-12-31 0 MARRIAGE OFFICIAL Bride 1962-09-27
## 76 B233p141 1998-01-30 1998-01-30 0 MARRIAGE OFFICIAL Bride 1978-08-06
## 77 B233p268 1998-02-12 1998-02-14 2 ELDER Bride 1980-06-29
## 78 B233p429 1998-02-27 1998-03-07 8 PASTOR Bride 1955-12-03
## 79 B233p674 1998-03-13 1998-04-04 22 CATHOLIC PRIEST Bride 1969-10-29
## 80 B233p903 1998-03-31 1998-03-31 0 MARRIAGE OFFICIAL Bride 1979-11-10
## 81 B233p1245 1998-04-23 1998-04-24 1 PASTOR Bride 1955-04-08
## 82 B233p1381 1998-05-01 1998-05-23 22 PASTOR Bride 1977-03-09
## 83 B233p1690 1998-05-26 1998-05-30 4 MINISTER Bride 1955-07-17
## 84 B233p1899 1998-06-09 1998-06-27 18 MARRIAGE OFFICIAL Bride 1979-03-18
## 85 B234p65 1998-06-18 1998-06-20 2 BISHOP Bride 1958-08-21
## 86 B234p438 1998-07-13 1998-08-01 19 PASTOR Bride 1930-08-03
## 87 B234p687 1998-07-31 1998-07-31 0 MARRIAGE OFFICIAL Bride 1925-10-29
## 88 B234p904 1998-08-13 1998-08-13 0 MARRIAGE OFFICIAL Bride 1944-02-28
## 89 B234p1292 1998-09-15 1998-09-26 11 PASTOR Bride 1976-02-13
## 90 B234p1485 1998-10-02 1998-10-02 0 MARRIAGE OFFICIAL Bride 1948-09-17
## 91 B234p1621 1998-10-14 1998-10-23 9 MINISTER Bride 1982-07-20
## 92 B234p1966 1998-11-09 1998-11-09 0 MARRIAGE OFFICIAL Bride 1980-08-03
## 93 B235p7 1998-11-12 1998-11-28 16 MINISTER Bride 1977-09-12
## 94 B235p259 1998-12-02 1998-12-05 3 PASTOR Bride 1967-06-08
## 95 B235p404 1998-12-14 1998-12-14 0 MARRIAGE OFFICIAL Bride 1961-06-24
## 96 B235p563 1998-12-23 1998-12-23 0 MARRIAGE OFFICIAL Bride 1976-01-21
## 97 B235p837 1999-01-22 1999-01-31 9 MINISTER Bride 1928-05-26
## 98 B235p992 1999-02-05 1999-02-06 1 MINISTER Bride 1972-08-31
## age race prevcount prevconc hs college dayOfBirth
## 1 32.60274 White 0 <NA> 12 7 102
## 2 32.29041 White 1 Divorce 12 0 219
## 3 34.79178 Hispanic 1 Divorce 12 3 51
## 4 40.57808 Black 1 Divorce 12 4 141
## 5 30.02192 White 0 <NA> 12 0 348
## 6 26.86301 White 1 <NA> 12 0 52
## 7 25.30685 White 1 Divorce 12 0 284
## 8 35.05205 White 1 Divorce 12 0 31
## 9 21.33699 Black 0 <NA> 12 0 338
## 10 45.75342 White 3 Divorce 12 6 183
## 11 42.16986 Black 1 Divorce 12 2 37
## 12 29.41370 White 1 Divorce 12 1 319
## 13 20.66301 White 0 <NA> 12 1 245
## 14 18.56438 White 0 <NA> 10 0 288
## 15 42.59178 White 1 Divorce 12 0 303
## 16 37.55068 American Indian 0 <NA> 12 4 332
## 17 31.42740 White 0 <NA> 12 2 30
## 18 19.16712 Black 0 <NA> 12 NA 139
## 19 54.50685 White 1 Death 12 NA 51
## 20 49.31507 White 1 Divorce 12 0 140
## 21 52.44384 White 1 Death 12 7 100
## 22 44.85479 Black 1 Divorce 9 0 334
## 23 39.02740 Black 1 Divorce 12 3 293
## 24 37.84384 White 1 Divorce 12 1 6
## 25 25.01370 White 1 Divorce 12 0 332
## 26 26.42192 White 0 <NA> 12 1 218
## 27 19.29041 Black 0 <NA> 12 0 294
## 28 18.36164 Black 0 <NA> 9 0 283
## 29 40.94521 White 2 Divorce 12 0 96
## 30 27.10685 White 0 <NA> 12 2 62
## 31 20.10685 White 0 <NA> 12 0 56
## 32 51.63014 White 2 Divorce 12 NA 262
## 33 23.11233 White 0 <NA> 12 5 108
## 34 34.00548 White 2 Divorce 12 4 157
## 35 23.38356 White 0 <NA> 12 4 44
## 36 41.59178 Black 0 <NA> 9 0 331
## 37 74.24658 White 1 Death 12 0 142
## 38 71.41918 White 1 Divorce 12 NA 77
## 39 57.24932 Black 1 Divorce 12 0 148
## 40 29.03562 White 0 <NA> 12 2 263
## 41 55.63562 White 2 Divorce 12 1 57
## 42 18.64110 White 0 <NA> 11 0 67
## 43 18.46301 Black 0 <NA> 12 0 149
## 44 20.21918 White 0 <NA> 12 2 257
## 45 43.82466 White 2 Divorce 12 NA 49
## 46 38.25753 White 1 Divorce 12 2 264
## 47 24.61096 White 0 <NA> 11 0 140
## 48 67.58356 White 1 Divorce 12 7 200
## 49 39.15890 White 5 Divorce 12 4 354
## 50 28.72603 White 0 <NA> 12 2 56
## 51 52.58904 White 0 <NA> 12 2 115
## 52 26.73699 White 0 <NA> 12 1 69
## 53 39.58356 Black 1 Divorce 12 1 138
## 54 23.99178 White 0 <NA> 12 6 358
## 55 25.12055 White 1 <NA> 12 2 323
## 56 25.14795 White 1 Divorce 12 0 342
## 57 20.44658 White 0 <NA> 10 0 249
## 58 20.04384 Black 0 <NA> 12 0 79
## 59 43.69589 White 1 Divorce 12 2 203
## 60 33.98356 Black 0 <NA> 12 2 103
## 61 23.96438 White 1 Divorce 12 0 116
## 62 17.01918 White 0 <NA> 11 0 114
## 63 20.26575 White 0 <NA> 10 0 32
## 64 37.93699 White 1 Divorce 12 0 176
## 65 39.29315 Black 1 Death 12 0 61
## 66 21.21644 White 0 <NA> 12 2 105
## 67 19.25479 White 0 <NA> 12 NA 107
## 68 49.76712 White 3 Divorce 12 NA 320
## 69 44.21644 White 1 Divorce 10 0 174
## 70 43.01918 White 2 Divorce 12 2 253
## 71 45.01644 Black 2 Divorce 12 0 275
## 72 27.43562 Black 0 <NA> 12 2 141
## 73 38.61918 White 2 Divorce 12 0 88
## 74 20.77534 White 1 Divorce 12 2 52
## 75 35.28493 White 2 Divorce 12 NA 270
## 76 19.49863 Black 0 <NA> 12 0 218
## 77 17.64110 Black 0 <NA> 9 0 181
## 78 42.28767 White 0 <NA> 12 6 337
## 79 28.44932 White 0 <NA> 12 5 302
## 80 18.40000 White 0 <NA> 11 0 314
## 81 43.07397 White 3 Divorce 10 0 98
## 82 21.21918 White 0 <NA> 12 3 68
## 83 42.89863 White 1 Divorce 12 0 198
## 84 19.29041 White 0 <NA> 12 0 77
## 85 39.85753 Black 0 <NA> 12 NA 233
## 86 68.04110 White 1 Death 12 5 215
## 87 72.80274 White 1 Divorce 12 2 302
## 88 54.49315 Black 1 Divorce 12 0 59
## 89 22.63288 White 0 <NA> 12 4 44
## 90 50.07397 White 3 Death 12 4 261
## 91 16.27123 White 0 <NA> 11 0 201
## 92 18.27945 Black 0 <NA> 12 0 216
## 93 21.22466 White 0 <NA> 12 NA 255
## 94 31.51507 White 1 Divorce 12 2 159
## 95 37.49863 White 3 Divorce 12 5 175
## 96 22.93699 White 1 Divorce 8 0 21
## 97 70.73151 White 2 Death 12 2 147
## 98 26.45205 White 0 <NA> 12 4 244
## sign
## 1 Aries
## 2 Leo
## 3 Pisces
## 4 Gemini
## 5 Saggitarius
## 6 Pisces
## 7 Libra
## 8 Aquarius
## 9 Saggitarius
## 10 Cancer
## 11 Aquarius
## 12 Scorpio
## 13 Virgo
## 14 Libra
## 15 Scorpio
## 16 Saggitarius
## 17 Aquarius
## 18 Taurus
## 19 Pisces
## 20 Taurus
## 21 Aries
## 22 Saggitarius
## 23 Libra
## 24 Capricorn
## 25 Saggitarius
## 26 Leo
## 27 Libra
## 28 Libra
## 29 Aries
## 30 Pisces
## 31 Pisces
## 32 Virgo
## 33 Aries
## 34 Gemini
## 35 Aquarius
## 36 Saggitarius
## 37 Gemini
## 38 Pisces
## 39 Gemini
## 40 Virgo
## 41 Pisces
## 42 Pisces
## 43 Gemini
## 44 Virgo
## 45 Pisces
## 46 Virgo
## 47 Gemini
## 48 Cancer
## 49 Saggitarius
## 50 Pisces
## 51 Taurus
## 52 Pisces
## 53 Taurus
## 54 Capricorn
## 55 Scorpio
## 56 Saggitarius
## 57 Virgo
## 58 Aries
## 59 Leo
## 60 Aries
## 61 Taurus
## 62 Taurus
## 63 Aquarius
## 64 Cancer
## 65 Pisces
## 66 Aries
## 67 Aries
## 68 Scorpio
## 69 Cancer
## 70 Virgo
## 71 Libra
## 72 Gemini
## 73 Aries
## 74 Pisces
## 75 Libra
## 76 Leo
## 77 Cancer
## 78 Saggitarius
## 79 Scorpio
## 80 Scorpio
## 81 Aries
## 82 Pisces
## 83 Cancer
## 84 Pisces
## 85 Leo
## 86 Leo
## 87 Scorpio
## 88 Pisces
## 89 Aquarius
## 90 Virgo
## 91 Cancer
## 92 Leo
## 93 Virgo
## 94 Gemini
## 95 Cancer
## 96 Aquarius
## 97 Gemini
## 98 Virgo
ggplot(data = Marriage, aes(x=age, fill=person))+
geom_histogram(binwidth = 1 , position = "dodge")
In the above visual, we can see how many brides and grooms got married
at what age. So it appears from this visual that maximum number of
persons got married around 20 years of age, and very few people got
married after 60.
ggplot(Marriage, aes(age, person)) +
geom_point(aes(color = officialTitle, shape = race), size = 2) +
facet_wrap(~sign)
Your objective for the next four questions will be write the code necessary to exactly recreate the provided graphics.
This boxplot was built using the mpg dataset. Notice the
changes in axis labels.
data("mpg")
mpg
## # A tibble: 234 × 11
## manufacturer model displ year cyl trans drv cty hwy fl class
## <chr> <chr> <dbl> <int> <int> <chr> <chr> <int> <int> <chr> <chr>
## 1 audi a4 1.8 1999 4 auto… f 18 29 p comp…
## 2 audi a4 1.8 1999 4 manu… f 21 29 p comp…
## 3 audi a4 2 2008 4 manu… f 20 31 p comp…
## 4 audi a4 2 2008 4 auto… f 21 30 p comp…
## 5 audi a4 2.8 1999 6 auto… f 16 26 p comp…
## 6 audi a4 2.8 1999 6 manu… f 18 26 p comp…
## 7 audi a4 3.1 2008 6 auto… f 18 27 p comp…
## 8 audi a4 quattro 1.8 1999 4 manu… 4 18 26 p comp…
## 9 audi a4 quattro 1.8 1999 4 auto… 4 16 25 p comp…
## 10 audi a4 quattro 2 2008 4 manu… 4 20 28 p comp…
## # … with 224 more rows
ggplot(mpg, aes(hwy, manufacturer)) +
geom_boxplot() +
labs(x="Highway Fuel Efficiency (miles/gallon)", y="Vehicle Manufacturer") +
theme_classic()
This graphic is built with the diamonds dataset in the
ggplot2 package.
data("diamonds")
diamonds
## # A tibble: 53,940 × 10
## carat cut color clarity depth table price x y z
## <dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <dbl> <dbl> <dbl>
## 1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43
## 2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31
## 3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31
## 4 0.29 Premium I VS2 62.4 58 334 4.2 4.23 2.63
## 5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75
## 6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48
## 7 0.24 Very Good I VVS1 62.3 57 336 3.95 3.98 2.47
## 8 0.26 Very Good H SI1 61.9 55 337 4.07 4.11 2.53
## 9 0.22 Fair E VS2 65.1 61 337 3.87 3.78 2.49
## 10 0.23 Very Good H VS1 59.4 61 338 4 4.05 2.39
## # … with 53,930 more rows
q3 <- ggplot(diamonds, aes(price, colour = cut, fill = cut)) +
geom_density(alpha = 0.2) +
scale_fill_discrete() +
labs(x = "Diamond Price ", y = "Density", title = "Diamond Price Density")+
theme_bw()
q3
This graphic uses the penguins dataset and shows the
counts between males and females by species.
data("penguins")
penguins
## # A tibble: 344 × 8
## species island bill_length_mm bill_depth_mm flipper_…¹ body_…² sex year
## <fct> <fct> <dbl> <dbl> <int> <int> <fct> <int>
## 1 Adelie Torgersen 39.1 18.7 181 3750 male 2007
## 2 Adelie Torgersen 39.5 17.4 186 3800 fema… 2007
## 3 Adelie Torgersen 40.3 18 195 3250 fema… 2007
## 4 Adelie Torgersen NA NA NA NA <NA> 2007
## 5 Adelie Torgersen 36.7 19.3 193 3450 fema… 2007
## 6 Adelie Torgersen 39.3 20.6 190 3650 male 2007
## 7 Adelie Torgersen 38.9 17.8 181 3625 fema… 2007
## 8 Adelie Torgersen 39.2 19.6 195 4675 male 2007
## 9 Adelie Torgersen 34.1 18.1 193 3475 <NA> 2007
## 10 Adelie Torgersen 42 20.2 190 4250 <NA> 2007
## # … with 334 more rows, and abbreviated variable names ¹​flipper_length_mm,
## # ²​body_mass_g
ggplot(penguins, aes(x = sex, fill = species)) +
geom_bar(alpha = 0.8) +
scale_fill_manual(values = c("darkorange","purple","cyan4"), guide = "none") +
theme_minimal() +
facet_wrap(~species, ncol = 1) +
coord_flip() +
labs(y="Count", x="Sex")
This figure examines the relationship between bill length and depth
in the penguins dataset.
data("penguins")
penguins
## # A tibble: 344 × 8
## species island bill_length_mm bill_depth_mm flipper_…¹ body_…² sex year
## <fct> <fct> <dbl> <dbl> <int> <int> <fct> <int>
## 1 Adelie Torgersen 39.1 18.7 181 3750 male 2007
## 2 Adelie Torgersen 39.5 17.4 186 3800 fema… 2007
## 3 Adelie Torgersen 40.3 18 195 3250 fema… 2007
## 4 Adelie Torgersen NA NA NA NA <NA> 2007
## 5 Adelie Torgersen 36.7 19.3 193 3450 fema… 2007
## 6 Adelie Torgersen 39.3 20.6 190 3650 male 2007
## 7 Adelie Torgersen 38.9 17.8 181 3625 fema… 2007
## 8 Adelie Torgersen 39.2 19.6 195 4675 male 2007
## 9 Adelie Torgersen 34.1 18.1 193 3475 <NA> 2007
## 10 Adelie Torgersen 42 20.2 190 4250 <NA> 2007
## # … with 334 more rows, and abbreviated variable names ¹​flipper_length_mm,
## # ²​body_mass_g
ggplot(penguins, aes(bill_length_mm,bill_depth_mm)) +
geom_point(aes(color = species, shape = species), size = 2) +
guides(shape = 'none') +
geom_smooth(method = "lm", se = FALSE, aes(color = species)) +
scale_color_manual(values = c("darkorange","darkorchid","cyan4")) +
labs(color = 'Species', x = 'Bill Length (mm)', y = 'Bill Depth (mm)')
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 2 rows containing non-finite values (stat_smooth).
## Warning: Removed 2 rows containing missing values (geom_point).