Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change wording to improve clarity when using arrange() with multiple variables #833

Closed
Charl-Hutchings opened this issue Jan 29, 2023 · 1 comment

Comments

@Charl-Hutchings
Copy link

This issue relates to the manipulating, analysing and exporting data with tidyverse, specifically the split-apply-combine section.

Currently the text regarding the use of arrange() with multiple variables read "With the above code, we can proceed with arrange() to sort the table according to a number of criteria so that we have a better comparison. For instance, we might want to arrange the table above in (i) an alphabetical order of the levels of the species and (ii) in descending order of the count".

surveys %>%
count(sex, species) %>%
arrange(species, desc(n))

outputs...

A tibble: 81 × 3

sex species n

1 F albigula 675
2 M albigula 502
3 NA albigula 75
4 NA audubonii 75
5 F baileyi 1646
6 M baileyi 1216
7 NA baileyi 29
8 NA bilineata 303
9 NA brunneicapillus 50
10 NA chlorurus 39

Having run this code when reviewing this lesson, I was somewhat confused as to why the output table did not appear to have 'n' in descending order. After a few minutes of playing around, I realised that the descending order of 'n' was within the species - with species in alphabetical order. I think that additional clarity is needed in the text to emphasise the importance of the order in which variables are passed to arrange().

@tobyhodges
Copy link
Member

Thanks @Charl-Hutchings for opening this issue. The lesson underwent a major update and reorganisation when #887 was merged. As your suggestion relates to content in a version of the lesson before that update took place, I will close it. Please open a new issue if you have suggestions for how the new content could be improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants