README.md

heor-logo-fullname-colour-dark-RGB

Developing HEOR R tools

The purpose of this package is to standardise and streamline the use of commonly employed functions and styles. So far it contains functions to apply universal HEOR figure style and to save the plot with an inclusion of HEOR logo.

Installation

The package is currently available for installation from github. To install from github, you need to use R library called devtools. ```{r eval = FALSE} install.packages("devtools") library(devtools) devtools::install_github("Alik-V/heor") library(heor)

Additionally, one of the implemented functions requres a one-time font installation.
The font installation may take a few minutes to complete.
```{r eval = FALSE}
install.packages("extrafont")
library(extrafont)
extrafont::font_import()

This will import the fonts currently installed in your system and will allow their further use with heor package.

Examples

Here are a few examples of the functions available now.

heor_style

This function has no arguments and is added to an existing ggplot2 figure either in ggplot chain or posthoc. We will use mtcars dataset as an example here. ```{r eval = FALSE} data(mtcars) my_scatplot <- ggplot(mtcars,aes(x=wt,y=mpg)) + geom_point() + xlab('Weight (x 1000lbs)') + ylab('Miles per Gallon') + geom_smooth() + labs(title = "Fuel efficiency in cars", subtitle="Bigger cars are less efficient")

![pre_heor_style](https://github.com/Alik-V/heor/blob/master/PNG/pre_heor_style.png)
```{r eval = FALSE}
myplot_style <- my_scatplot + heor_style()

heor_style_no_logo

heor_style_minimal()

Minimalistic version of HEOR style with smaller axis titles. ``` {r eval=FALSE} myplot_min <- my_scatplot + heor_style_minimal()

![heor_style_minimal](https://github.com/Alik-V/heor/blob/master/PNG/heor_style_minimal.png)  


## heorTheme
An updated version of heor_style. This can be used as an additional ggplot2 parameter similar to *+heor_style()*, 
and allows additional customization at a cost of user argument input.

```{r eval = FALSE}
data(line_plot)

# replace all character variables to ensure ggplot keeps the plotting order correct
line_plot$treatment <- as.character(line_plot$treatment)
line_plot$treatment <- factor(line_plot$treatment,levels=unique(line_plot$treatment))

lineplot <- ggplot() +
  geom_line(data=line_plot, mapping=aes(x=time,y=hba1c,colour=treatment), linetype="solid", alpha=1.0, size=0.7) +
  geom_hline(yintercept=c(8.0,9.0), colour="black", linetype="dashed", size=0.4) +
  scale_x_continuous("Time (Years)", breaks=seq(0,40,5), limits=c(0,40), expand=c(0,0)) +
  scale_y_continuous("HbA1c (%)", breaks=seq(6.5,10.0,0.5), limits=c(6.5,10.0), expand=c(0,0)) +
  labs(title="Plot Title",
       subtitle="Plot Subtitle",
       caption="Example caption text") +
  heorTheme(line_plot, 
            "Tahoma", 
            0.9, 
            "treatment")

heorTheme_2

finalise_plot

This function allows you to save your plot in a specified location, with specified size and the source of the data. It will also add HEOR logo in the footer (by default), however it can be any other image/logo. {r eval = FALSE} finalise_plot(plot_name = myplot_min, source = "Source: Motor trends dataset",, save_filepath = "filename_that_my_plot_should_be_saved_to-nc.png", width_pixels = 640, height_pixels = 450, logo_image_path = "logo_image_filepath.png" ) heor_style

plot_grid

For details, see the vignette.



Alik-V/heor documentation built on April 4, 2020, 9:38 p.m.