I have data that I made a histogram for (ur_memr_t$up...). I then used fitdistr to fit an exponential dist to the data. I captured the parameters for the fitted distribution and generated some random variates. I then made a density curve for the exp random variates. I want to place the density over the histogram. The following code throws this error
exp_data <- data.frame( x = rexp(3000, rate = 0.0144896182))
ggplot(data = ur_memr_t, aes(ur_memr_t$updated_days_to_next_ur)) +
geom_histogram() + ggplot(exp_data, aes(x)) + geom_density()
Error in p + o : non-numeric argument to binary operator
In addition: Warning message:
Incompatible methods ("+.gg", "Ops.data.frame") for "+"
If I run
ggplot(data = ur_memr_t, aes(ur_memr_t$updated_days_to_next_ur)) +
geom_histogram()
and
ggplot(exp_data, aes(x)) + geom_density()
seperately, they produce correct plots. Why will they not work together and plot one on top of the other?