Skip to content

Commit

Permalink
added image
Browse files Browse the repository at this point in the history
  • Loading branch information
trinker committed Dec 22, 2016
1 parent c5ad0b7 commit 1b50bf2
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 4 deletions.
12 changes: 11 additions & 1 deletion 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, ggplot2)
pacman::p_load(numform, xtable, wakefield, ggplot2, knitr)
rinline <- function(code) {
sprintf('<code class="r">``` `r %s` ```</code>', code)
}
Expand All @@ -18,6 +18,16 @@ ver <- gsub(regex, "\\2", desc[loc])
verbadge <- sprintf('<a href="https://img.shields.io/badge/Version-%s-orange.svg"><img src="https://img.shields.io/badge/Version-%s-orange.svg" alt="Version"/></a></p>', ver, ver)
````

```{r, echo=FALSE, message=FALSE, warning=FALSE}
knit_hooks$set(htmlcap = function(before, options, envir) {
if(!before) {
paste('<p class="caption"><b><em>',options$htmlcap,"</em></b></p>",sep="")
}
})
knitr::opts_knit$set(self.contained = TRUE, cache = FALSE)
knitr::opts_chunk$set(fig.path = "inst/figure/")
```

[![Build Status](https://travis-ci.org/trinker/numform.svg?branch=master)](https://travis-ci.org/trinker/numform)
[![Coverage Status](https://coveralls.io/repos/trinker/numform/badge.svg?branch=master)](https://coveralls.io/r/trinker/numform?branch=master)
`r verbadge`
Expand Down
52 changes: 49 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Table of Contents
- [[Commas](#commas)](#[commas](#commas))
- [[Percents](#percents)](#[percents](#percents))
- [[Dollars](#dollars)](#[dollars](#dollars))
- [[Plotting](#plotting)](#[plotting](#plotting))
- [[Modeling](#modeling)](#[modeling](#modeling))

Installation
Expand All @@ -41,7 +42,8 @@ run `R CMD INSTALL` on it, or use the **pacman** package to install the
development version:

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 All @@ -61,7 +63,7 @@ formats individual values in the vector while the latter uses the vector
to compute a calculation on each of the values and then formats them.

<!-- html table generated in R 3.3.2 by xtable 1.8-2 package -->
<!-- Thu Dec 22 10:40:32 2016 -->
<!-- Thu Dec 22 11:37:07 2016 -->
<table>
<tr>
<td>
Expand Down Expand Up @@ -146,6 +148,9 @@ fv_num_percent
</td>
</tr>
</table>
<p class="caption">
<b><em>Available Formatting Functions</em></b>
</p>
Demonstration
=============

Expand Down Expand Up @@ -241,6 +246,47 @@ Dollars
## [1] "$0.00" "$0.00" "$0.20" "$-.02"
## [5] "$1,122,222.00" "$3.14"

Plotting
--------

library(tidyverse)

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()

## # A tibble: 10,000 × 8
## revenue date site dollar thous thous_dollars abb_month
## <dbl> <date> <chr> <chr> <chr> <chr> <chr>
## 1 485137.9 1999-12-01 Site 5 $485000 485K $485K D
## 2 557003.2 1999-12-13 Site 5 $557000 557K $557K D
## 3 504327.6 1999-07-28 Site 5 $504000 504K $504K J
## 4 499311.9 1999-12-06 Site 1 $499000 499K $499K D
## 5 515171.6 1999-06-15 Site 4 $515000 515K $515K J
## 6 591029.9 1999-07-31 Site 3 $591000 591K $591K J
## 7 539718.0 1999-04-07 Site 3 $540000 540K $540K A
## 8 430662.6 1999-01-10 Site 5 $431000 431K $431K J
## 9 464238.4 1999-04-08 Site 5 $464000 464K $464K A
## 10 465105.9 1999-01-05 Site 5 $465000 465K $465K J
## # ... with 9,990 more rows, and 1 more variables: abb_week <chr>

![](inst/figure/unnamed-chunk-10-1.png)

Modeling
--------

Expand Down Expand Up @@ -302,4 +348,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.
Binary file added inst/figure/unnamed-chunk-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1b50bf2

Please sign in to comment.