I have 2 histograms which i would like to combine into one plot. Somehow i cannot add both of them together. One data frame has length of 1000 and the other has a length of 1000.
The following code gives me an error:
Error: `mapping` must be created by `aes()`
How can i go about combining them with a legend?
p <-ggplot(prediction_3)+
geom_histogram(aes(x=prediction_3), binwidth = 0.01)
p + geom_histogram(prediction_2b, aes(x=prediction),binwidth = 0.01, fill = "red", alpha = 0.7)+
geom_vline(xintercept=prediction_1)+
geom_text(aes(0.5,prediction_1,label = 0.469, vjust = 1))
The individual histogram plots are as follows:
Any help will be appreciated. thank you
EDIT:
prediction_2b$value <- 'prediction_2b'
prediction_3$value <- 'prediction_3'
combined_pred <- rbind(prediction_2b, prediction_3)
an error appears:
Error in match.names(clabs, names(xi)) : names do not match previous names