I would like to combine these two ggplots
: origin from different data frames with the same X axis (floor_date
s) and same facet_wrap
.
The two plots:
ggplot(averaged_activity,aes(x=date(DATETIME),y=PERCENTAGE), group = POPULATION) +
geom_line(stat = "summary", fun = "mean")+ geom_point(stat = "summary", fun = "mean")+
labs(y="Activity (%)", x = "Date")+
scale_x_date(date_labels="%d/%m/%y",date_breaks ="1 week")+
scale_y_continuous()+
facet_wrap(~POPULATION, ncol=1)
ggplot(info_table, aes(x=floor_date(DATE_OF_METAMORPHOSIS, unit = "week"), group= POPULATION))+
geom_histogram()+facet_wrap(~POPULATION, ncol=1)
looks like:
I would like the two plots to be combined on the same graph.
I've tried to add the histogram to the first ggplot
with geom_histogram(info_table, aes(x=floor_date(DATE_OF_METAMORPHOSIS, unit = "week"), group= POPULATION))
, I also tried to create the ggplot with no defined data frame and define the data frames inside the geoms. but every way I tried I got a different error, all about r having trouble finding variables, like the "POPULATION" variable in the facet or the group commend or the "PERCENTAGE" variable in the y axis.
tnx!