Skip to content

Commit

Permalink
added more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
trinker committed Sep 20, 2016
1 parent 5c30d99 commit 7cc2be9
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 2 deletions.
35 changes: 34 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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)
````

[![Build Status](https://travis-ci.org/trinker/numform/svg?branch=master)](https://travis-ci.org/trinker/numform)
[![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 All @@ -45,10 +45,43 @@ You are welcome to:

# Demonstration

## Load Packages

```{r}
if (!require("pacman")) install.packages("pacman")
pacman::p_load_gh("trinker/numform")
pacman::p_load(dplyr)
```

## Numbers

```{r, warn=FALSE}
f_num(c(0.0, 0, .2, -00.02, 1.122222, pi, "A"))
```

## Commas

```{r, warn=FALSE}
f_comma(c(1234.12345, 1234567890, .000034034, 123000000000, -1234567))
```

## Percents

```{r, warn=FALSE}
f_percent(c(30, 33.45, .1), 1)
f_percent(c(0.0, 0, .2, -00.02, 1.122222, pi))
f_prop2percent(c(.30, 1, 1.01, .33, .222, .01))
```

## Dollars

```{r, warn=FALSE}
f_dollar(c(0, 30, 33.45, .1))
f_dollar(c(0.0, 0, .2, -00.02, 1122222, pi)) %>%
f_comma()
```

## Modeling

We can see its use in actual model reporting as well:

Expand Down
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ numform


[![Build
Status](https://travis-ci.org/trinker/numform/svg?branch=master)](https://travis-ci.org/trinker/numform)
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)
<a href="https://img.shields.io/badge/Version-0.0.1-orange.svg"><img src="https://img.shields.io/badge/Version-0.0.1-orange.svg" alt="Version"/></a>
Expand All @@ -19,6 +19,12 @@ Table of Contents
- [[Installation](#installation)](#[installation](#installation))
- [[Contact](#contact)](#[contact](#contact))
- [[Demonstration](#demonstration)](#[demonstration](#demonstration))
- [[Load Packages](#load-packages)](#[load-packages](#load-packages))
- [[Numbers](#numbers)](#[numbers](#numbers))
- [[Commas](#commas)](#[commas](#commas))
- [[Percents](#percents)](#[percents](#percents))
- [[Dollars](#dollars)](#[dollars](#dollars))
- [[Modeling](#modeling)](#[modeling](#modeling))

Installation
============
Expand Down Expand Up @@ -47,13 +53,62 @@ You are welcome to:
Demonstration
=============

Load Packages
-------------

if (!require("pacman")) install.packages("pacman")
pacman::p_load_gh("trinker/numform")
pacman::p_load(dplyr)

Numbers
-------

f_num(c(0.0, 0, .2, -00.02, 1.122222, pi, "A"))

## Warning in f_num(c(0, 0, 0.2, -0.02, 1.122222, pi, "A")): NAs introduced by
## coercion

## [1] ".0" ".0" ".2" "-.0" "1.1" "3.1" NA

Commas
------

f_comma(c(1234.12345, 1234567890, .000034034, 123000000000, -1234567))

## [1] "1,234.123" "1,234,567,890" ".000034034" "123,000,000,000"
## [5] "-1,234,567"

Percents
--------

f_percent(c(30, 33.45, .1), 1)

## [1] "30.0%" "33.5%" ".1%"

f_percent(c(0.0, 0, .2, -00.02, 1.122222, pi))

## [1] ".0%" ".0%" ".2%" "-.0%" "1.1%" "3.1%"

f_prop2percent(c(.30, 1, 1.01, .33, .222, .01))

## [1] "30.0%" "100.0%" "101.0%" "33.0%" "22.2%" "1.0%"

Dollars
-------

f_dollar(c(0, 30, 33.45, .1))

## [1] "$0.00" "$30.00" "$33.45" "$0.10"

f_dollar(c(0.0, 0, .2, -00.02, 1122222, pi)) %>%
f_comma()

## [1] "$0.00" "$0.00" "$0.20" "$-.02"
## [5] "$1,122,222.00" "$3.14"

Modeling
--------

We can see its use in actual model reporting as well:

mod1 <- t.test(1:10, y = c(7:20))
Expand Down

0 comments on commit 7cc2be9

Please sign in to comment.