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(dslabs)Warning: package 'dslabs' was built under R version 4.5.3
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(ggplot2)
data(heights)tall_males <-heights$sex=="Male" & heights$height>70
head(tall_males)[1] TRUE FALSE FALSE TRUE FALSE FALSE
s <-heights%>% filter(sex== "Female")%>%
summarize(average=mean(height), standard_deviation = sd(height))
s average standard_deviation
1 64.93942 3.760656
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
table(heights$sex)
Female Male
238 812
heights %>% ggplot(aes(sex, fill=sex)) + geom_bar()heights %>% count(sex) %>% mutate(proportion = n/sum(n)) #gives us the propotion sex n proportion
1 Female 238 0.2266667
2 Male 812 0.7733333
murders %>% ggplot(aes(region, fill= region)) + geom_bar() + scale_fill_manual(values=c("red","white","lightgray","darkgray"))