From caf62b31ada5e7b22fcde211a5637a759281bdb8 Mon Sep 17 00:00:00 2001 From: Nima Rafati Date: Mon, 28 Oct 2024 21:36:20 +0100 Subject: [PATCH] Correct calculation of mode --- slide_r_basic_statistic.Rmd | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/slide_r_basic_statistic.Rmd b/slide_r_basic_statistic.Rmd index f1a523c..99f3bd3 100644 --- a/slide_r_basic_statistic.Rmd +++ b/slide_r_basic_statistic.Rmd @@ -201,8 +201,10 @@ text(x = var2_mode - 90 , y = 600, labels = paste("Mode =", round(var2_mode, 2)) ``` ```{r mode, echoo = T, eval = T} -mode(data$var1) -mode(data$var2) +density_data1 <- density(data$var1) +density_data1$x[which.max(density_data1$y)] +density_data2 <- density(data$var2) +density_data2$x[which.max(density_data2$y)] ``` --- name: Spread