Welcome in the group !
I think that it would help very much if you included a (small) example of the data that you want to use.
Further some suggestions:
- enclosing your code in three (or four in case of Rmd chunks) backticks makes it better readable
- indicate more clearly what is the error (if any) that you are encountering.
- you seem to use a function
sort_desc
that I do not know. So this is no code that we (I) can run to see what is wrong. Try to create a reprex ! The main points for areprex
: be as clear as possible and make the problem as small as possible. For example I do not think that the fact that this is running in an Rmd environment matters (but of course I may be wrong).