library(tidyverse)
## ── 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
I’m an R Markdown document!
Here’s a code chunk that samples from a normal distribution:
samp = rnorm(100)
length(samp)
## [1] 100
I can take the mean of the sample, too! The mean is 0.2126354.
This is code for the learning assessment at P8105
la_df =
tibble(
norm_samp = rnorm(n = 500, mean = 1),
norm_samp_pos = norm_samp > 0,
abs_norm_samp = abs(norm_samp)
)
ggplot(la_df, aes(x = abs_norm_samp)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
median_samp = median(pull(la_df, norm_samp))
The median of the variable containing absolute values is 1.09.