From 38c9561ab9b80cf73de8df7b1ce7c399cb516d2b Mon Sep 17 00:00:00 2001 From: "Albert Y. Kim" Date: Fri, 1 Feb 2019 08:02:48 -0500 Subject: [PATCH] Update README.md example code Hello, I'm thrilled to see this package! This PR adds code to your example to make it a fully-functioning [reprex](https://www.jessemaegan.com/post/so-you-ve-been-asked-to-make-a-reprex/). * Explicitly creates a data frame `life_df`. Judging by the fact that your `ggplot` involved a variable `lifeExp`, I'm 99.7% certain this was based on `gapminder` data! * Loads the `ggplot2` and `bbplot` packages explicitly * Makes the plot object name in both code chunks match. --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e46712f..1b1ecd9 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,22 @@ The function is pretty basic and does not change or adapt based on the type of c Example of how it is used in a standard workflow: ``` -line <- ggplot(line_df, aes(x = year, y = lifeExp)) + +# Create line_df data frame of life expectancy in the UK using gapminder data +library(gapminder) +library(dplyr) +line_df <- gapminder %>% + filter(country == "United Kingdom") + +# Create plot +library(ggplot2) +library(bbplot) +my_line_plot <- ggplot(line_df, aes(x = year, y = lifeExp)) + geom_line(colour = "#007f7f", size = 1) + geom_hline(yintercept = 0, size = 1, colour="#333333") + bbc_style() + +# View plot +my_line_plot ``` ### `finalise_plot`