How to plot two histograms together in R?

I am using R and I have two data frames: carrots and cucumbers. Each data frame has a single numeric column that lists the length of all measured carrots (total: 100k carrots) and cucumbers (total: 50k cucumbers).

I wish to plot two histograms – carrot length and cucumbers lengths – on the same plot. They overlap, so I guess I also need some transparency. I also need to use relative frequencies not absolute numbers since the number of instances in each group is different.

Something like this would be nice but I don’t understand how to create it from my two tables:

overlapped density

9 Answers
9

Leave a Comment