error in reorder the bars of ggplots
0
0
Entering edit mode
2.4 years ago
Kai_Qi ▴ 130

I am using ggplot to plot the geneontology results: I use the following code:

p <- ggplot(data=mydata_2, aes(x=Term, y=logPValue), size =1) + geom_bar(stat='identity')


It worked. But When I want to reorder the columns from high to low using y value using:

p <- ggplot(data=mydata_2, aes(x=(Term, -logPValue), y=logPValue), size =0.01) + geom_bar(stat='identity')


it showed an error:

error: unexpected ',' in "p <- ggplot(data=mydata_2, aes(x=(Term,"

Why this happened. I searched a while. A lot of people is using this method.

RNA-Seq R rna-seq software error • 1.2k views
2
Entering edit mode
x =reorder(Term, -logPValue) should work

1
Entering edit mode

x=(Term, -logPValue) there's your error, did you forget the function?

0
Entering edit mode

I saw a lot of people say it will work. But It did not work in my hand. In the end, I use mutate(Term = fct_reorder(Term, logPValue)) to make it work.

I still do not know the reason.