diff --git a/NEWS.md b/NEWS.md index c067a18..38b7e19 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ # forestploter 1.1.2 -* Draw reference line and other vertical lines under whiskers. +* Draw reference line and other vertical lines below whiskers. +* Allow minor ticks and groups for diamond shapes. +* Able to change legend size. # forestploter 1.1.1 diff --git a/README.Rmd b/README.Rmd index c0bfe65..46f2859 100644 --- a/README.Rmd +++ b/README.Rmd @@ -22,7 +22,7 @@ knitr::opts_chunk$set( [![Codecov test coverage](https://codecov.io/gh/adayim/forestploter/branch/main/graph/badge.svg)](https://app.codecov.io/gh/adayim/forestploter?branch=main) -The goal of `forestploter` is to create a publication-ready forest plot with little effort. This package provide some extra displays compared to other packages. The dataset will be used as a basic layout for the forest plot. Width of the column to draw the confidence interval can be controlled with the string length of the column. Can use space to control this. The elements in the plot are put in the row and columns, think the plot as a table. +The goal of `forestploter` is to create a publication-ready forest plot with little effort. This package provides some extra displays compared to other packages. The dataset will be used as a basic layout for the forest plot. The width of the column to draw the confidence interval can be controlled with the string length of the column. Can use space to control this. The elements in the plot are put in the rows and columns, think of the plot as a table. ## Installation @@ -49,7 +49,7 @@ library(forestploter) dt <- read.csv(system.file("extdata", "example_data.csv", package = "forestploter")) -# indent the subgroup if there is a number in the placebo column +# Indent the subgroup if there is a number in the placebo column dt$Subgroup <- ifelse(is.na(dt$Placebo), dt$Subgroup, paste0(" ", dt$Subgroup)) @@ -59,7 +59,7 @@ dt$Treatment <- ifelse(is.na(dt$Treatment), "", dt$Treatment) dt$Placebo <- ifelse(is.na(dt$Placebo), "", dt$Placebo) dt$se <- (log(dt$hi) - log(dt$est))/1.96 -# Add blank column for the forest plot to display CI. +# Add a blank column for the forest plot to display CI. # Adjust the column width with space. dt$` ` <- paste(rep(" ", 20), collapse = " ") @@ -93,7 +93,7 @@ plot(p) ``` ## Editing plot -Sometimes one may want to change the color or font face of some columns. Or one may want to insert text into certain rows. Or may want an underline to separate by group. The function `edit_plot`, `add_text`, `insert_text` and `add_border` can achieve these. Below is how to do this: +Sometimes one may want to change the color or font face of some columns. Or one may want to insert text into certain rows. Or may want an underline to separate by group. The function `edit_plot`, `add_text`, `insert_text`, and `add_border` can achieve these. Below is how to do this: ```{r edit, dpi=300, fig.width = 12, fig.height = 6.3, out.height = '40%'} # Edit text in row 3 @@ -104,7 +104,7 @@ g <- edit_plot(g, row = c(2, 5, 8, 11, 15, 18), gp = gpar(fontface = "bold")) -# Insert text at top +# Insert text at the top g <- insert_text(g, text = "Treatment group", col = 2:3, @@ -117,7 +117,7 @@ g <- add_border(g, part = "header", row = 2, where = "bottom") g <- add_border(g, part = "header", row = 1, col = 2:3, gp = gpar(lwd = 2)) -# Edit background of row 5 +# Edit the background of row 5 g <- edit_plot(g, row = 5, which = "background", gp = gpar(fill = "darkolivegreen1")) @@ -136,15 +136,15 @@ Remember to add 1 to the row number if you have inserted any text before. The ro ## Complex usage -If you want to draw CI to multiple columns, only need to provide a vector of the position of the columns to be drawn in the data. As seen in the example below, the CI will be drawn in the column 3 and 5. The first and second `est`, `lower` and `upper` will be drawn in column 3 and column 5. +If you want to draw CI to multiple columns, only need to provide a vector of the position of the columns to be drawn in the data. As seen in the example below, the CI will be drawn in columns 3 and 5. The first and second `est`, `lower`, and `upper` will be drawn in columns 3 and column 5. -For a more complex example, you may want to draw CI by groups. The solution is simple, just provide another set of `est`, `lower` and `upper`. If the number of provided `est`, `lower` and `upper` are larger than the column number to draw CI, then the `est`, `lower` and `upper` will be reused. As it is shown in the example below, `est_gp1` and `est_gp2` will be drawn in column 3 and column 5 as normal. But `est_gp3` and `est_gp4` hasn't been used, those will be drawn to column 3 and column 5 again. So, the `est_gp1` and `est_gp2` will be considered as group 1, `est_gp3` and `est_gp4` group 2. +For a more complex example, you may want to draw CI by groups. The solution is simple, just provide another set of `est`, `lower`, and `upper`. If the number of provided `est`, `lower`, and `upper` are larger than the column number to draw CI, then the `est`, `lower`, and `upper` will be reused. As it is shown in the example below, `est_gp1` and `est_gp2` will be drawn in column 3 and column 5 as normal. But `est_gp3` and `est_gp4` haven't been used, those will be drawn to column 3 and column 5 again. So, the `est_gp1` and `est_gp2` will be considered as group 1, `est_gp3` and `est_gp4` group 2. This is an example of multiple CI columns and groups: ```{r multiple, dpi=300, fig.width = 12, fig.height = 7.3, out.height = '80%'} -# Add blank column for the second CI column +# Add a blank column for the second CI column dt$` ` <- paste(rep(" ", 20), collapse = " ") # Set-up theme diff --git a/README.md b/README.md index 3f8ae02..ed8a303 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ coverage](https://codecov.io/gh/adayim/forestploter/branch/main/graph/badge.svg) The goal of `forestploter` is to create a publication-ready forest plot -with little effort. This package provide some extra displays compared to -other packages. The dataset will be used as a basic layout for the -forest plot. Width of the column to draw the confidence interval can be -controlled with the string length of the column. Can use space to -control this. The elements in the plot are put in the row and columns, -think the plot as a table. +with little effort. This package provides some extra displays compared +to other packages. The dataset will be used as a basic layout for the +forest plot. The width of the column to draw the confidence interval can +be controlled with the string length of the column. Can use space to +control this. The elements in the plot are put in the rows and columns, +think of the plot as a table. ## Installation @@ -51,7 +51,7 @@ library(forestploter) dt <- read.csv(system.file("extdata", "example_data.csv", package = "forestploter")) -# indent the subgroup if there is a number in the placebo column +# Indent the subgroup if there is a number in the placebo column dt$Subgroup <- ifelse(is.na(dt$Placebo), dt$Subgroup, paste0(" ", dt$Subgroup)) @@ -61,7 +61,7 @@ dt$Treatment <- ifelse(is.na(dt$Treatment), "", dt$Treatment) dt$Placebo <- ifelse(is.na(dt$Placebo), "", dt$Placebo) dt$se <- (log(dt$hi) - log(dt$est))/1.96 -# Add blank column for the forest plot to display CI. +# Add a blank column for the forest plot to display CI. # Adjust the column width with space. dt$` ` <- paste(rep(" ", 20), collapse = " ") @@ -100,7 +100,7 @@ plot(p) Sometimes one may want to change the color or font face of some columns. Or one may want to insert text into certain rows. Or may want an underline to separate by group. The function `edit_plot`, `add_text`, -`insert_text` and `add_border` can achieve these. Below is how to do +`insert_text`, and `add_border` can achieve these. Below is how to do this: ``` r @@ -112,7 +112,7 @@ g <- edit_plot(g, row = c(2, 5, 8, 11, 15, 18), gp = gpar(fontface = "bold")) -# Insert text at top +# Insert text at the top g <- insert_text(g, text = "Treatment group", col = 2:3, @@ -125,7 +125,7 @@ g <- add_border(g, part = "header", row = 2, where = "bottom") g <- add_border(g, part = "header", row = 1, col = 2:3, gp = gpar(lwd = 2)) -# Edit background of row 5 +# Edit the background of row 5 g <- edit_plot(g, row = 5, which = "background", gp = gpar(fill = "darkolivegreen1")) @@ -148,17 +148,17 @@ before. The row number will be changed after inserting a text. If you want to draw CI to multiple columns, only need to provide a vector of the position of the columns to be drawn in the data. As seen -in the example below, the CI will be drawn in the column 3 and 5. The -first and second `est`, `lower` and `upper` will be drawn in column 3 -and column 5. +in the example below, the CI will be drawn in columns 3 and 5. The first +and second `est`, `lower`, and `upper` will be drawn in columns 3 and +column 5. For a more complex example, you may want to draw CI by groups. The -solution is simple, just provide another set of `est`, `lower` and -`upper`. If the number of provided `est`, `lower` and `upper` are larger -than the column number to draw CI, then the `est`, `lower` and `upper` -will be reused. As it is shown in the example below, `est_gp1` and -`est_gp2` will be drawn in column 3 and column 5 as normal. But -`est_gp3` and `est_gp4` hasn’t been used, those will be drawn to column +solution is simple, just provide another set of `est`, `lower`, and +`upper`. If the number of provided `est`, `lower`, and `upper` are +larger than the column number to draw CI, then the `est`, `lower`, and +`upper` will be reused. As it is shown in the example below, `est_gp1` +and `est_gp2` will be drawn in column 3 and column 5 as normal. But +`est_gp3` and `est_gp4` haven’t been used, those will be drawn to column 3 and column 5 again. So, the `est_gp1` and `est_gp2` will be considered as group 1, `est_gp3` and `est_gp4` group 2. @@ -166,7 +166,7 @@ This is an example of multiple CI columns and groups: ``` r -# Add blank column for the second CI column +# Add a blank column for the second CI column dt$` ` <- paste(rep(" ", 20), collapse = " ") # Set-up theme diff --git a/cran-comments.md b/cran-comments.md index 5c0edc7..706f472 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -11,4 +11,4 @@ There were no ERRORs or WARNINGs. --- -This version includes 1 bug fix improvement. +This version includes 3 fix improvement. diff --git a/man/figures/README-edit-1.png b/man/figures/README-edit-1.png index 9844d42..e438a0c 100644 Binary files a/man/figures/README-edit-1.png and b/man/figures/README-edit-1.png differ diff --git a/man/figures/README-example-1.png b/man/figures/README-example-1.png index 16c44b0..697a9f0 100644 Binary files a/man/figures/README-example-1.png and b/man/figures/README-example-1.png differ diff --git a/man/figures/README-multiple-1.png b/man/figures/README-multiple-1.png index dccd970..0fe4825 100644 Binary files a/man/figures/README-multiple-1.png and b/man/figures/README-multiple-1.png differ