Much of the work in this class will be done via R Markdown documents. R Markdown documents are documents that combine text, R code, and R output, including figures. They are a great way to produce self-contained and documented statistical analyses.
In this first worksheet, you will learn how to do some basic markdown editing. After you have made a change to the document, press “Knit HTML” in R Studio and see what kind of a result you get.
Edit only below this line.
Try out basic R Markdown features, as described here: https://rmarkdown.rstudio.com/authoring_basics.html. Write some text that is bold, and some that is in italics. Make a numbered list and a bulleted list. Make a nested list. Try the block-quote feature.
Name: Mais Alraee
Position: Math instructor
list_1 <- list(1:6, letters[1:5])
list_2 <- list(5:11, letters[6:11])
my_nested_list <- list(list_1, list_2)
my_nested_list
## [[1]]
## [[1]][[1]]
## [1] 1 2 3 4 5 6
##
## [[1]][[2]]
## [1] "a" "b" "c" "d" "e"
##
##
## [[2]]
## [[2]][[1]]
## [1] 5 6 7 8 9 10 11
##
## [[2]][[2]]
## [1] "f" "g" "h" "i" "j" "k"
Talented data scientists leverage data that everybody sees; visionary data scientists leverage data that nobody sees.-Vincent Granville.
“Data that is loved tends to survive.” - Kurt Bollacker
R code embedded in R chunks will be executed and the output will be shown.
# R code goes here
x <- rnorm(100) # random sample from normal distribution
dens <- density(x) # calculate density
dens
##
## Call:
## density.default(x = x)
##
## Data: x (100 obs.); Bandwidth 'bw' = 0.3699
##
## x y
## Min. :-4.1207 Min. :0.0001272
## 1st Qu.:-2.1514 1st Qu.:0.0164938
## Median :-0.1822 Median :0.0539411
## Mean :-0.1822 Mean :0.1268244
## 3rd Qu.: 1.7871 3rd Qu.:0.2685626
## Max. : 3.7563 Max. :0.3542984
plot(dens) # plot density
Now you try it. For example, take the built-in data set
cars
, which lists speed and stopping distance for cars from
the 1920. Plot speed vs. distance, and/or perform a correlation
analysis. Then write a few sentences describing what you see.
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.1.3
## -- Attaching packages --------------------------------------- tidyverse 1.3.2 --
## v ggplot2 3.3.6 v purrr 0.3.4
## v tibble 3.1.7 v dplyr 1.0.9
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.1.3
## Warning: package 'tibble' was built under R version 4.1.3
## Warning: package 'tidyr' was built under R version 4.1.3
## Warning: package 'readr' was built under R version 4.1.3
## Warning: package 'purrr' was built under R version 4.1.3
## Warning: package 'dplyr' was built under R version 4.1.3
## Warning: package 'stringr' was built under R version 4.1.3
## Warning: package 'forcats' was built under R version 4.1.3
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
cars <- cars
ggplot(data = cars) +
ggtitle("Speed Vs.Distance") +
geom_point(mapping = aes(x = speed, y = dist))