Skip to content

Instantly share code, notes, and snippets.

View Kumquatum's full-sized avatar

Gwenaëlle Lemoine Kumquatum

View GitHub Profile
@Kumquatum
Kumquatum / ggplot_orderingObjects.R
Created October 27, 2017 20:23
Ordering objects inside ggplot with reorder()
# Setup
library(ggplot2)
# Sample set
fruit <- matrix(c("Apple","186","Banana","93","Elderberry","48","Durian", "28","Cherry", "28"), ncol = 2, byrow = TRUE)
colnames(fruit) <- c("Name","Freq")
fruit <- as.data.frame(fruit)
fruit$Freq <- as.numeric(as.character(fruit$Freq))
# Plot graph