我正在尝试制作一个条形图,其中从miRNA最高value到最高的顺序排列情节miRNA。为什么我的代码不起作用?> head(corr.m) miRNA variable value1 mmu-miR-532-3p pos 72 mmu-miR-1983 pos 753 mmu-miR-301a-3p pos 704 mmu-miR-96-5p pos 55 mmu-miR-139-5p pos 106 mmu-miR-5097 pos 47ggplot(corr.m, aes(x=reorder(miRNA, value), y=value, fill=variable)) + geom_bar(stat="identity")
2 回答
牧羊人nacy
TA贡献1862条经验 获得超7个赞
您的代码工作正常,但条形图从低到高排序。如果您想要从高到低订购酒吧,您必须在-之前添加标志value:
ggplot(corr.m, aes(x = reorder(miRNA, -value), y = value, fill = variable)) +
geom_bar(stat = "identity")
使用数据:
corr.m <- structure(list(miRNA = structure(c(5L, 2L, 3L, 6L, 1L, 4L), .Label = c("mmu-miR-139-5p", "mmu-miR-1983", "mmu-miR-301a-3p", "mmu-miR-5097", "mmu-miR-532-3p", "mmu-miR-96-5p"), class = "factor"),
variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "pos", class = "factor"),
value = c(7L, 75L, 70L, 5L, 10L, 47L)),
class = "data.frame", row.names = c("1", "2", "3", "4", "5", "6"))
- 2 回答
- 0 关注
- 5104 浏览
添加回答
举报
0/150
提交
取消