error in reorder the bars of ggplots
0
0
Entering edit mode
4.6 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.9k views
ADD COMMENT
2
Entering edit mode
x =reorder(Term, -logPValue) should work
ADD REPLY
1
Entering edit mode

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

ADD REPLY
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.

ADD REPLY

Login before adding your answer.

Traffic: 1866 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6