Hi I been getting Aesthetics error when trying to only display labels for certain subsets. For example.
library("ggplot2")
library(gplots)
library(ggrepel)
set.seed(10)
data <- data.frame(label=letters[1:21], number= runif(21, min=0, max=100))
data$label <-factor(data$label)
ggplot(data, aes(x=label, y=number, fill=data$label )) +
geom_bar(stat="identity") +
geom_text_repel(data= data[data$number > 80,], aes(label =data$label ),
arrow = arrow(length = unit(0.01, 'npc')), box.padding = unit(1.5, 'lines'),color="black" )
When I do this I get the following error
Error: Aesthetics must be either length 1 or the same as the data (2): label, x, y, fill
even if I replace the label with a vector such as c("label1","label2")
I still get an error.
I'm doing something wrong but I can't figure it out. The only way I can do this is to create a separate vector with the same length and use that as the label, however I think there is a way to subset directly. thanks!