This is some strange data to be looking at presenting with a histogram, but never mind. I'd use ggplot2
. If you melt the data (using reshape2
) then the number of vectors or their length is irrelevant.
df <- data.frame(male=c(0,0,1,0,1),
female=c(1,1,0,0,0),
unknown=c(0,0,0,1,0))
df.m <- melt(df)
str(df.m)
hist(df.m$value ~ df.m$variable)
ggplot(df.m, aes(value)) + geom_histogram(aes(fill=variable)) +
facet_wrap(~variable) #This depends on how you want your different variables split up.
#If you want them on the same plot, then:
ggplot(df.m, aes(value)) + geom_histogram(aes(fill=variable), position="dodge")