Browse Source

spell check example tweak

0.7.0
boB Rudis 7 years ago
parent
commit
d76d1e962d
  1. 17
      R/check.r
  2. 17
      README.Rmd
  3. 31
      README.md
  4. BIN
      README_files/figure-markdown_github/unnamed-chunk-10-1.png
  5. 18
      man/gg_check.Rd

17
R/check.r

@ -1,7 +1,9 @@
#' Spell check ggplot2 plot labels
#'
#' This function can be used in a piping context or standalone. Current
#' functionality only looks for misspelled words in the labels of ggplot2 objects.
#' Due to the way ggplot2 objects are created, this has to be used in a
#' standalone context.
#'
#' Current functionality only looks for misspelled words in the labels of ggplot2 objects.
#' When misspelled words are found, a message is printed with the words and the
#' label that they are in. No messages will be printed if there are no misspelled
#' words.
@ -17,20 +19,9 @@
#'
#' df <- data.frame(x=c(20, 25, 30), y=c(4, 4, 4), txt=c("One", "Two", "Three"))
#'
#' # piping
#' ggplot(mtcars, aes(mpg, wt)) +
#' geom_point() +
#' geom_text(data=df, aes(x=x, y=y, label=txt)) +
#' labs(x="This is some txt", y="This is more text",
#' title="Thisy is a titlle",
#' subtitle="This is a subtitley",
#' caption="This is a captien") %>%
#' gg_check()
#'
#' # not piping
#' ggplot(mtcars, aes(mpg, wt)) +
#' geom_point() +
#' geom_text(data=df, aes(x=x, y=y, label=txt)) +
#' labs(x="This is some txt", y="This is more text",
#' title="Thisy is a titlle",
#' subtitle="This is a subtitley",

17
README.Rmd

@ -131,26 +131,13 @@ count(mpg, class) %>%
```{r fig.retina=2, message=TRUE}
df <- data.frame(x=c(20, 25, 30), y=c(4, 4, 4), txt=c("One", "Two", "Three"))
# piped
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
geom_text(data=df, aes(x=x, y=y, label=txt)) +
labs(x="This is some txt", y="This is more text",
title="Thisy is a titlle",
subtitle="This is a subtitley",
caption="This is a captien") %>%
gg_check()
# not-piped
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
geom_text(data=df, aes(x=x, y=y, label=txt)) +
labs(x="This is some txt", y="This is more text",
title="Thisy is a titlle",
subtitle="This is a subtitley",
caption="This is a captien") -> gg
caption="This is a captien") +
theme_ipsum_rc(grid="XY") -> gg
gg_check(gg)
```

31
README.md

@ -139,36 +139,13 @@ count(mpg, class) %>%
``` r
df <- data.frame(x=c(20, 25, 30), y=c(4, 4, 4), txt=c("One", "Two", "Three"))
# piped
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
geom_text(data=df, aes(x=x, y=y, label=txt)) +
labs(x="This is some txt", y="This is more text",
title="Thisy is a titlle",
subtitle="This is a subtitley",
caption="This is a captien") %>%
gg_check()
```
## Possible misspelled words in [title]: (Thisy, titlle)
## Possible misspelled words in [subtitle]: (subtitley)
## Possible misspelled words in [caption]: (captien)
<img src="README_files/figure-markdown_github/unnamed-chunk-10-1.png" width="672" />
``` r
# not-piped
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
geom_text(data=df, aes(x=x, y=y, label=txt)) +
labs(x="This is some txt", y="This is more text",
title="Thisy is a titlle",
subtitle="This is a subtitley",
caption="This is a captien") -> gg
caption="This is a captien") +
theme_ipsum_rc(grid="XY") -> gg
gg_check(gg)
```
@ -179,7 +156,7 @@ gg_check(gg)
## Possible misspelled words in [caption]: (captien)
<img src="README_files/figure-markdown_github/unnamed-chunk-10-2.png" width="672" />
<img src="README_files/figure-markdown_github/unnamed-chunk-10-1.png" width="672" />
### Test Results
@ -190,7 +167,7 @@ library(testthat)
date()
```
## [1] "Sat Feb 11 20:45:48 2017"
## [1] "Sat Feb 11 20:58:58 2017"
``` r
test_dir("tests/")

BIN
README_files/figure-markdown_github/unnamed-chunk-10-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 61 KiB

18
man/gg_check.Rd

@ -18,8 +18,11 @@ gg_check(gg, dict = hunspell::dictionary("en_US"),
the object that was passed in
}
\description{
This function can be used in a piping context or standalone. Current
functionality only looks for misspelled words in the labels of ggplot2 objects.
Due to the way ggplot2 objects are created, this has to be used in a
standalone context.
}
\details{
Current functionality only looks for misspelled words in the labels of ggplot2 objects.
When misspelled words are found, a message is printed with the words and the
label that they are in. No messages will be printed if there are no misspelled
words.
@ -29,20 +32,9 @@ library(ggplot2)
df <- data.frame(x=c(20, 25, 30), y=c(4, 4, 4), txt=c("One", "Two", "Three"))
# piping
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
geom_text(data=df, aes(x=x, y=y, label=txt)) +
labs(x="This is some txt", y="This is more text",
title="Thisy is a titlle",
subtitle="This is a subtitley",
caption="This is a captien") \%>\%
gg_check()
# not piping
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
geom_text(data=df, aes(x=x, y=y, label=txt)) +
labs(x="This is some txt", y="This is more text",
title="Thisy is a titlle",
subtitle="This is a subtitley",

Loading…
Cancel
Save