My dataframe column for the x-axis values is in the correct decreasing order that I want it, but the ggplot x-axis is rearranging the values according to alphabetical order. Basically, my x-axis variable contains a "Baseline" value, a range of treatment days "TD1, TD2, ..." values that are a different quantity for each subject, and a "Post" value.
Currently, ggplot reorders this alphabetically as 'Baseline, Post, TDx...', when clearly I need it to just follow the order of the dataframe.
How do I solve this? Can I do it in ggplot syntax, or is there a way to set the order of the variable before I pass the dataframe to ggplot? I cannot seem to find an answer that works.
Thanks in advance!