Skip to content

Commit

Permalink
P value stars
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Apr 28, 2017
1 parent d0f71f6 commit 4be1aa3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -3,3 +3,4 @@
S3method(print,emoji)
export(ji)
export(ji_find)
export(ji_p)
25 changes: 25 additions & 0 deletions R/ji_p.R
@@ -0,0 +1,25 @@
#' Summarise your p-values with emoji
#'
#' @param x A vector of p-values.
#' @export
#' @examples
#' emo::ji_p(1)
#' emo::ji_p(0.1)
#' emo::ji_p(0.05)
#' emo::ji_p(0.01)
#' emo::ji_p(1e-6)
#'
#' emo::ji_p(rbeta(50, 2, 5))
ji_p <- function(x) {
stopifnot(is.numeric(x))

out <- stats::symnum(x,
corr = FALSE,
na = FALSE,
cutpoints = c(0, 1e-5, 0.001, 0.01, 0.05, 0.1, 1),
symbols = c(ji("laughing"), ji("joy"), ji("grin"), ji("smile"), ji("thinking"), ji("poop"))
)

structure(out, class = c("emoji", class(out)))

}
23 changes: 23 additions & 0 deletions man/ji_p.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4be1aa3

Please sign in to comment.