---
title: "Contour-enhanced Forest Plot Example"
author: "Umar Hussain"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Contour-enhanced Forest Plot Example}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r}

# taking data from our paper published in Eur J Orthod 

df <- data.frame(
  study   = c("Ulger 2006", "Cook 1994", "Zervas 2016", "Haralabakis 2003"),
  year    = c(2006, 1994, 2016, 2003),
  n.e     = c(12, 30, 22, 30),
  mean.e  = c(0.67, -0.28, -1.13, 24.9),
  sd.e    = c(0.65, 1.35, 1.69, 5.2),
  n.c     = c(12, 30, 19, 22),
  mean.c  = c(0.58, -0.63, -0.09, 23.4),
  sd.c    = c(0.79, 1.46, 1.89, 4.2)
)

# reaname mean , n and sd to our function 
library(dplyr)

df <- df %>%
  rename(
    Study   = study,
    n_t     = n.e,
    mean_t  = mean.e,
    sd_t    = sd.e,
    n_c     = n.c,
    mean_c  = mean.c,
    sd_c    = sd.c
  )




```


```{r,fig.width=11, fig.height=6}
library(contourforest)
# modifying values of  position to have beautiful plot 
forest_cont(df,
            title = "FMA of cervical Headgear vs \n control group",
            study_x = -6.5,
            treatment_x = -4,
            control_x = -2.5, 
            sort = "effect",
            effect_x = 2, 
            weight_x = 4.5,
            PredInt_x =  2,
            
            contour_left_min  = c(-1.3, -0.5, -0.2, 0),
            contour_left_max  = c(-0.5, -0.2,  0,   0.2),
            contour_right_min = c(0, 0.2, 0.5, 0.8),
            contour_right_max = c(0.2, 0.5, 0.8, 1.8),)

```

