coe_comp = function(coe_1, coe_2, para="all",
range=c(max(min(coe_1$length), min(coe_2$length)),
min(max(coe_1$length), max(coe_2$length))),
legend=c("coe_1", "coe_2")){
cs_stack = rbind(coe_1[,1:3],coe_2[,1:3])
cs_stack$type =c(rep(legend[1], nrow(coe_1)),
rep(legend[2], nrow(coe_2)))
cs_stack_range = cs_stack[cs_stack$length>=range[1]&cs_stack$length<=range[2], ]
if (para=="all"){
print(ggplot(data=cs_stack_range, aes(x=length, y=estimates, color=type))+
geom_line()+
geom_point()+
facet_grid(para ~ ., scales="free")+
scale_colour_brewer(palette="Dark2"))
cs_merge = merge(coe_1[,1:3], coe_2[,1:3],
by=c("length", "para"), suffixes=c("_1", "_2"))
print(ggplot(data=cs_merge, aes(x=estimates_1, y=estimates_2))+
geom_point()+
geom_smooth(method="lm")+
facet_wrap(~para, scales="free"))
} else {
cs_stack_para = cs_stack_range[cs_stack_range$para==para, ]
ggplot(data=cs_stack_para, aes(x=length, y=estimates, color=type))+
geom_point()+
geom_line()+
scale_colour_brewer(palette="Dark2")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.