1

Is it possible to plot, in the same plot, histograms for data coming from two different data.frames in ggplot?

The answer to this question provides the right plots (in terms of the looks); however, it mandates that the data is combined in one data.frame. This is quite tough for me as the data.frames have many columns which are different, and a straightforward rbind() does not work

Community
  • 1
  • 1
cross
  • 1,018
  • 13
  • 32
  • 1
    If `rbind` would solve your problem, you may want to use the `rbindlist` function from the `data.table` package, which has an option (`fill` and `use.names`) to just fill in `NA` for any columns that don't overlap. – MichaelChirico Aug 02 '15 at 19:17

1 Answers1

0

I assume you have a single set of x/y coordinates that you are plotting at a time? If so, you could just create a dataframe that has just the data for those two columns, plus the "fill" column as is used in the answer to the linked question.

hoffmanc
  • 614
  • 9
  • 16
  • this [link](https://stackoverflow.com/questions/22600390/creating-density-plots-from-two-different-data-frames-using-ggplot2) works for me – Jia Gao Feb 07 '18 at 06:25