Skip to content

Commit

Permalink
Update the lab
Browse files Browse the repository at this point in the history
  • Loading branch information
nimarafati committed Oct 21, 2024
1 parent 0d5d65b commit e09ec93
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lab_statistics.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit e09ec93

Please sign in to comment.