This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
You can also embed plots, for example:
#Palmer Penguins Note that the
echo = FALSE parameter was
added to the code chunk to prevent printing of the R code that generated
the plot.
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.4.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)
library(palmerpenguins)
## Warning: package 'palmerpenguins' was built under R version 4.4.3
ggplot(data=penguins)+
geom_smooth(mapping = aes(x=flipper_length_mm,y=body_mass_g))+
geom_point(mapping = aes(x=flipper_length_mm,y=body_mass_g))
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).
ggplot(data=penguins)+
geom_smooth(mapping = aes(x=flipper_length_mm,y=body_mass_g,linetype = species))
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 2 rows containing non-finite outside the scale range
## (`stat_smooth()`).
ggplot(data=penguins)+
geom_jitter(mapping = aes(x=flipper_length_mm,y=body_mass_g))
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).
ggplot(data=diamonds)+
geom_bar(mapping = aes(x=cut, color=cut, fill=cut))
ggplot(data=diamonds)+
geom_bar(mapping = aes(x=cut, fill = clarity))
ggplot(data=penguins,aes(x=flipper_length_mm,y=body_mass_g))+
geom_point(aes(color=species))+
facet_grid(sex~species)+
facet_grid(~sex)
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).
ggplot(data=diamonds)+
geom_bar(mapping = aes(x=color, fill = cut))+
facet_wrap(~cut)
library(ggplot2)
library(palmerpenguins)
ggplot(data=penguins)+
geom_point(mapping=aes(x=flipper_length_mm,y=body_mass_g,color=species))+
labs(title = "Palmer Penguins: Body Mass vs. Flipper Length", subtitle = "Sample of Three Penguins",
caption="Data collected by Dr. Gorman")+
annotate("text",x=220,y=3500,label="The Gentoos are the largest", color="purple", fontface="bold",size=4.5, angle=25)
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).
p<- ggplot(data=penguins)+
geom_point(mapping=aes(x=flipper_length_mm,y=body_mass_g,color=species))+
labs(title = "Palmer Penguins: Body Mass vs. Flipper Length", subtitle = "Sample of Three Penguins",
caption="Data collected by Dr. Gorman")
p+annotate("text",x=200,y=3500,label="The Gentoos are the largest")
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).
ggsave("Three penguin species.png")
## Saving 7 x 5 in image
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`geom_point()`).