Skip to content

Commit

Permalink
added plot example readme
Browse files Browse the repository at this point in the history
  • Loading branch information
trinker committed Dec 22, 2016
1 parent a0705cd commit c5ad0b7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Description: Format numbers for publication; includes the removal of
p-value formatter.
Depends: R (>= 3.2.0)
Suggests: testthat
Date: 2016-12-20
Date: 2016-12-22
License: GPL-2
LazyData: TRUE
Roxygen: list(wrap = FALSE)
Expand Down
33 changes: 31 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ output:
---

```{r, echo=FALSE}
pacman::p_load(numform, xtable, wakefield)
pacman::p_load(numform, xtable, wakefield, ggplot2)
rinline <- function(code) {
sprintf('<code class="r">``` `r %s` ```</code>', code)
}
Expand All @@ -32,7 +32,8 @@ Download the [zip ball](https://github.com/trinker/numform/zipball/master) or [t

```r
if (!require("pacman")) install.packages("pacman")
pacman::p_load_gh("trinker/numform")
pacman::p_load_current_gh("trinker/numform")
pacman::p_load(tidyverse)
```

# Contact
Expand Down Expand Up @@ -107,6 +108,34 @@ f_dollar(c(0.0, 0, .2, -00.02, 1122222, pi)) %>%
f_comma()
```

## Plotting

```r
library(tidyverse)
```

```{r}
data_frame(
revenue = rnorm(10000, 500000, 50000),
date = sample(seq(as.Date('1999/01/01'), as.Date('2000/01/01'), by="day"), 10000, TRUE),
site = sample(paste("Site", 1:5), 10000, TRUE)
) %>%
mutate(
dollar = f_dollar(revenue, digits = -3),
thous = f_thous(revenue),
thous_dollars = f_thous(revenue, prefix = '$'),
abb_month = f_month(date),
abb_week = f_weekday(date, distinct = TRUE)
) %T>%
print() %>%
ggplot(aes(abb_week, revenue)) +
geom_jitter(width = .2, height = 0, alpha = .2) +
scale_y_continuous(label = function(x) x %>% f_thous(x, prefix = '$'))+
facet_wrap(~site) +
theme_bw()
```


## Modeling

We can see its use in actual model reporting as well:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,4 @@ chunk:
And then use <code class="r">`` `r report(mymod)` ``</code> resulting in
a report that looks like this: F(5, 30) = 36.07, p &lt; .05. For
&Chi;<sup>2</sup> using proper HTML leads to &Chi;<sup>2</sup>(1) = .64,
p = .42.
p = .42.

0 comments on commit c5ad0b7

Please sign in to comment.