Skip to main content

mtcars-easystats

datawrangling
tidyverse
eda
en
mtcars
Published

September 7, 2024

Provide an overview of descriptive statistics on the mtcars dataset using the R package easystats.











Starting R packages:

library(easystats) 
## # Attaching packages: easystats 0.7.6.3 (red = needs update)
## ✖ bayestestR  0.19.0   ✔ correlation 0.8.8 
## ✖ datawizard  1.4.0    ✔ effectsize  1.0.3 
## ✖ insight     1.5.4    ✖ modelbased  0.17.0
## ✖ performance 0.18.2   ✖ parameters  0.29.3
## ✔ report      0.6.4    ✖ see         0.14.2
## 
## Restart the R-Session and update packages with `easystats::easystats_update()`.
library(tidyverse)  # comfort
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.1     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.3     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter()        masks stats::filter()
## ✖ dplyr::lag()           masks stats::lag()
## ✖ dplyr::recode_values() masks datawizard::recode_values()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Providing the dataset mtcars:

data(mtcars)

Here are some descriptive statistics for the metric variables of the dataset:

describe_distribution(mtcars) 
Variable Mean SD IQR Range Skewness Kurtosis n n_Missing
mpg 20.09 6.03 7.53 (10.40, 33.90) 0.67 -0.02 32 0
cyl 6.19 1.79 4.00 (4.00, 8.00) -0.19 -1.76 32 0
disp 230.72 123.94 221.53 (71.10, 472.00) 0.42 -1.07 32 0
hp 146.69 68.56 84.50 (52.00, 335.00) 0.80 0.28 32 0
drat 3.60 0.53 0.84 (2.76, 4.93) 0.29 -0.45 32 0
wt 3.22 0.98 1.19 (1.51, 5.42) 0.47 0.42 32 0
qsec 17.85 1.79 2.02 (14.50, 22.90) 0.41 0.86 32 0
vs 0.44 0.50 1.00 (0.00, 1.00) 0.26 -2.06 32 0
am 0.41 0.50 1.00 (0.00, 1.00) 0.40 -1.97 32 0
gear 3.69 0.74 1.00 (3.00, 5.00) 0.58 -0.90 32 0
carb 2.81 1.62 2.00 (1.00, 8.00) 1.16 2.02 32 0

What about statistics for the non-metric (nominal) variables (columns)? Let’s restrict the analysis to the columns vs, am, and gear.

data_tabulate(mtcars, select = c("vs", "am", "gear"))
Frequency Table
Variable Value N Raw % Valid % Cumulative %
vs 0 18 56.25 56.25 56.25
1 14 43.75 43.75 100.00
(NA) 0 0.00 (NA) (NA)
am 0 19 59.38 59.38 59.38
1 13 40.62 40.62 100.00
(NA) 0 0.00 (NA) (NA)
gear 3 15 46.88 46.88 46.88
4 12 37.50 37.50 84.38
5 5 15.62 15.62 100.00
(NA) 0 0.00 (NA) (NA)

Aufgabenname: mtcars-easystats