From e09ec93c196635d02c6805ca4dd022b54a9ed78f Mon Sep 17 00:00:00 2001 From: Nima Rafati Date: Mon, 21 Oct 2024 16:16:49 +0200 Subject: [PATCH] Update the lab --- lab_statistics.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lab_statistics.Rmd b/lab_statistics.Rmd index c9a59c8..e1de078 100644 --- a/lab_statistics.Rmd +++ b/lab_statistics.Rmd @@ -233,7 +233,7 @@ plot(dataset$Variable_1, dataset$Variable_2, main = 'Variable_1 vs Variable_2', ## Spearman's correlation - You can calculate Spearman's correlation using the same function (`cor`) for both numerical and categorical data. - Check the result of Spearman's correlation and Pearson's correlation for `Variable_1` and `Variable_2`. -- Calculate the correlation between `Category_1` and `Variable_1`. +- Calculate the correlation between `Category_1` and `Variable_1`. Consider `Category_1` with ordinal variable such as level of satisfaction labeled as **Category_A to E**. **Note:** Categorical_data cannot be directly passed to `cor`. You first need to encode the values as factors (the values are presented in form of `levels`) by `as.factor`. Then by converting the vector (e.g. `dataset$Category_1`) to numeric by `as.numeric` function, you can pass it to `cor` function. ```{r spearman, accordion = T}