I would like to label every column with the count value of Fill_factor for that specific column, but i can not get more than one label per column.
mydata.df <- data.frame(Fill_factor = c("Fill1", "Fill3", "Fill1", "FILL2","Fill1","Fill1","FILL2", "FILL2","FILL3" ), Count = c("AA", "BB", "AA", "AA","CC","BB","AA", "BB", "CC" ))
q <- qplot(Count, data= mydata.df, fill= Fill_factor, geom="bar", position="fill") # base sub by gene names
q + theme(axis.text.x=element_text(angle=-90, hjust = 1), text = element_text(size=10))
table(mydata.df$Count,mydata.df$Fill_factor)
Fill1 FILL2 Fill3 FILL3
AA 2 2 0 0
BB 1 1 1 0
CC 1 0 0 1
I have use also the function ddply but i don´t know how to get the right position
mydata.df.count <- ddply(mydata.df, .(Fill_factor, Count), nrow)
colnames(mydata.df.count) <- c("Fill_factor", "Count", "Frequency")
mydata.df.count <- ddply(mydata.df.count, .(Count), transform, pos = cumsum(Frequency)/5) # incorrect position
p = ggplot(mydata.df.count, aes(x = Count, y = Frequency), stat="identity") + geom_bar(aes(fill = Fill_factor), position="fill") + geom_text(aes(label = Frequency, y = pos), size = 5)
p
How can I place text labels in the right position (multiple text per column) using the position="fill" argument? and how could i sort the levels of Count to order for the highest Fill factor == "fill1"counts?
Thanks!