Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added pc for pretty comma print and added s/e to f to allow starting …
…and ending character additions.
- Loading branch information
Showing
8 changed files
with
97 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
Package: digit | ||
Title: Tools to Format Numbers for Publication | ||
Version: 0.0.1 | ||
Authors@R: c(person("Tyler", "Rinker", email = "tyler.rinker@gmail.com", role = c("aut", "cre"))) | ||
Authors@R: c(person("Tyler", "Rinker", email = | ||
"tyler.rinker@gmail.com", role = c("aut", "cre"))) | ||
Maintainer: Tyler Rinker <tyler.rinker@gmail.com> | ||
Description: Format numbers for publication; includes the removal of leading zeros, standardization of number of digits, and a p-value formatter. | ||
Description: Format numbers for publication; includes the removal of | ||
leading zeros, standardization of number of digits, and a | ||
p-value formatter. | ||
Depends: R (>= 3.2.0) | ||
Suggests: testthat | ||
Date: 2015-05-13 | ||
Date: 2015-09-25 | ||
License: GPL-2 | ||
LazyData: TRUE | ||
Roxygen: list(wrap = FALSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
|
||
export(f) | ||
export(p) | ||
export(pc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#' Comma Format Large Integers | ||
#' | ||
#' Add commas to larger integers. | ||
#' | ||
#' @param x A vector opc numbers (or string equivalents). | ||
#' @param big.mark The character to include every n places. | ||
#' @param \ldots Other arguments passed to \code{\link[base]{prettyNum}}. | ||
#' @return Returns a comma separted string of publication ready digits. | ||
#' @export | ||
#' @seealso \code{\link[base]{prettyNum}} | ||
#' @examples | ||
#' set.seed(4) | ||
#' pc(sample(4:10, 5)^5) | ||
#' ## pc(sample(4:10, 5)^5, ".") | ||
pc <- function(x, big.mark = ",", ...) { | ||
|
||
prettyNum(x, big.mark, ...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
% Generated by roxygen2 (4.1.1): do not edit by hand | ||
% Please edit documentation in R/pc.R | ||
\name{pc} | ||
\alias{pc} | ||
\title{Comma Format Large Integers} | ||
\usage{ | ||
pc(x, big.mark = ",", ...) | ||
} | ||
\arguments{ | ||
\item{x}{A vector opc numbers (or string equivalents).} | ||
|
||
\item{big.mark}{The character to include every n places.} | ||
|
||
\item{\ldots}{Other arguments passed to \code{\link[base]{prettyNum}}.} | ||
} | ||
\value{ | ||
Returns a comma separted string of publication ready digits. | ||
} | ||
\description{ | ||
Add commas to larger integers. | ||
} | ||
\examples{ | ||
set.seed(4) | ||
pc(sample(4:10, 5)^5) | ||
## pc(sample(4:10, 5)^5, ".") | ||
} | ||
\seealso{ | ||
\code{\link[base]{prettyNum}} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
context("Checking pc") | ||
|
||
test_that("pc ...",{ | ||
|
||
expect_true(nchar(pc(123456789)) == 11) | ||
|
||
}) | ||
|