1 + 1[1] 2
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.
When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
1 + 1[1] 2
You can add options to executable code like this
[1] 4
The echo: false option disables the printing of code (only output is displayed).
library(ggplot2)library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
library(dslabs)
library(ggplot2)
data(heights)
data(murders)
heights %>% group_by(sex) %>%
summarize(avg=mean(height), stdev=sd(height))# A tibble: 2 × 3
sex avg stdev
<fct> <dbl> <dbl>
1 Female 64.9 3.76
2 Male 69.3 3.61
heights %>% group_by(sex) %>%
summarize(avg=mean(height), stdev=sd(height))# A tibble: 2 × 3
sex avg stdev
<fct> <dbl> <dbl>
1 Female 64.9 3.76
2 Male 69.3 3.61
data("murders")
murders %>%
arrange(population) %>%
head() state abb region population total
1 Wyoming WY West 563626 5
2 District of Columbia DC South 601723 99
3 Vermont VT Northeast 625741 2
4 North Dakota ND North Central 672591 4
5 Alaska AK West 710231 19
6 South Dakota SD North Central 814180 8
library(ggplot2)
table(heights$sex)
Female Male
238 812
heights %>% ggplot(aes(sex, fill=sex)) + geom_bar()heights %>% count(sex) %>%
mutate(proportion = n/sum(n)) sex n proportion
1 Female 238 0.2266667
2 Male 812 0.7733333
library(ggplot2)
heights %>%
ggplot(aes(sex, fill=sex)) +
geom_bar()heights %>%
ggplot(aes(sex, fill=sex)) +
geom_bar() +
scale_fill_manual(values=c("purple", "green"))heights %>%
ggplot(aes(sex, height, fill=sex)) +
geom_boxplot() +
scale_fill_manual(values=c("red", "blue","green", "black"))