Categorical Data in the Tidyverse fct_*()

Hi, i cannot make reprex, but i got a little! problem. :expressionless:

when i plot this simple dataframe
eins

it leads to the following output and everything is fine

however when i want to plot ordered data
drei

it leads to the following output and makes absolutely no sense to me

why is this?

You are trying to reorder by another variable which is not what fct_infreq() does:

Also what issues did you have which prevented you making a reprex?

Thanks for fast respond. I will try the fct_reorder() function

The problem with reprex is that it gives me following error message:

pandoc.exe: \: openBinaryFile: does not exist (No such file or directory)
Fehler: pandoc document conversion failed with error 1
Ausführung angehalten

It seems that it is caused by the storage location which is a network drive and i cannot access my local storage such as C: since im working in a company and i have no permission currently. same problem for example when i try to knit a markdown document. i have done a lot research on that topic but found no suitable solution how to handle that

the fct_reorder() function apparently leads to this:

fct_reorder() is the function you want (reorder a factor by another variable), but the issue in your plot is that you're mapping the wrong variable to the y-axis. Try this:

ggplot(test, aes(fct_reorder(Name, Number), Number)) +
    geom_col()

geom_col() expects the y-axis to be a number, and you were mapping it to a reordered factor (look at the values on your axis, you're lining up A with A, B with B, etc.

That is a problem with the reprex package but not a reason for not providing a reproducible example (sample data on a copy/paste friendly format and formatted code) instead of screenshots.

I knew it was that easy, Thank You!

Your definitely right, Sir!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.