Q:

getting a ggplot2 to display relative contributions of each element to the total

genocount <-ggplot(SNPs, aes(genotype))
genocount + geom_bar()

Creates this Bar Chart:

I would like to be able to display the percentage contribution per chromosome to each genotype in a stacked orientation (those are displayed along the x axis). I've tried some methods that I've seen suggested by others, but they return different errors...I'm not sure if there's an incompatibility with my data set or if it's something else. 
Thanks for your help!
library(scales)

ggplot(SNPs, aes(genotype))
    genocount + geom_bar(aes(position = "fill", fill = chromosome))+
    geom_text(aes(label = percent(chromosome/sum(chromosome))))
    scale_y_continuous(labels = percent_format())

A:

I know exactly what you mean.
In the case of a bar chart the code is the following
ggplot(mydf) +
geom_bar(aes(x = var1,y = (..count..)/sum(..count..)),
stat = "count",position = "identity")

In the case of an histogram, the code is the following:
ggplot(data = df) +
geom_histogram(aes(x = var1, y = (..count..)/sum(..count..)),
position = "identity")

Don't ask me what is ..count..
I only know it is a black magic that works

