Skip to content

Commit 65c0c33

Browse files
committed
Add additional examples
1 parent e8630eb commit 65c0c33

File tree

10 files changed

+62
-2
lines changed

10 files changed

+62
-2
lines changed

R/asciiAnova.r

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
##' @export
2+
##' @examples
3+
##' op <- options(asciiType = "org")
4+
##' local({x <- 1:10; y <- rnorm(length(x),1+x); ascii(anova(lm(y~x)))})
5+
##' options(op)
26
##' @method ascii anova
37
ascii.anova <- function (x, include.rownames = TRUE, include.colnames = TRUE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = TRUE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...){
48
x <- as.data.frame(x, check.names = FALSE)

R/asciiDataFrame.r

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
##' @export
2+
##' @examples
3+
##' op <- options(asciiType = "org")
4+
##' ascii(data.frame(a = 1:3, b = 2), include.rownames = FALSE, digits = 0)
5+
##' options(op)
26
##' @method ascii data.frame
37
ascii.data.frame <- function(x, include.rownames = TRUE, include.colnames = TRUE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = TRUE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...) {
48

R/asciiGlm.r

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
##' @export
2+
##' @examples
3+
##' op <- options(asciiType = "org")
4+
##' local({x <- 1:10; y <- rnorm(length(x), 1+x); ascii(glm(y~x)) })
5+
##' options(op)
26
##' @method ascii glm
37
ascii.glm <- function (x, include.rownames = TRUE, include.colnames = TRUE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = TRUE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...){
48
x <- as.data.frame(summary(x)$coef)
@@ -20,6 +24,10 @@ ascii.glm <- function (x, include.rownames = TRUE, include.colnames = TRUE, rown
2024
}
2125

2226
##' @export
27+
##' @examples
28+
##' op <- options(asciiType = "org")
29+
##' local({x <- 1:10; y <- rnorm(length(x), 1+x); ascii(summary(glm(y~x))) })
30+
##' options(op)
2331
##' @method ascii summary.glm
2432
ascii.summary.glm <- function (x, include.rownames = TRUE, include.colnames = TRUE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = TRUE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...){
2533
x <- as.data.frame(x$coef)

R/asciiHtest.r

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
##' @export
2+
##' @examples
3+
##' op <- options(asciiType = "org")
4+
##' local({x <- rnorm(100); ascii(t.test(x))})
5+
##' options(op)
26
##' @method ascii htest
37
ascii.htest <- function(x, include.rownames = TRUE, include.colnames = TRUE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = TRUE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...){
48
if (x$method == "Fisher's Exact Test for Count Data") {

R/asciiList.r

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
##' @export
2+
##' @examples
3+
##' op <- options(asciiType = "org")
4+
##' ascii(list(a=1,b=2), list.type="label")
5+
##' options(op)
26
##' @method ascii list
37
ascii.list <- function(x, caption = NULL, caption.level = NULL, list.type = "bullet", ...) {
48
obj <- asciiList$new(x = x, caption = caption, caption.level = caption.level, list.type = list.type)
@@ -14,6 +18,10 @@ ascii.simple.list <- function(x, caption = NULL, caption.level = NULL, list.type
1418
}
1519

1620
##' @export
21+
##' @examples
22+
##' op <- options(asciiType = "org")
23+
##' ascii(sessionInfo())
24+
##' options(op)
1725
##' @method ascii packageDescription
1826
ascii.packageDescription <- function(x, caption = NULL, caption.level = NULL, list.type = "label", ...) {
1927
x <- unclass(x)

R/asciiLm.r

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
##' @export
2+
##' @examples
3+
##' op <- options(asciiType = "org")
4+
##' local({x <- 1:10; y <- rnorm(length(x), 1+x); ascii(lm(y~x)) })
5+
##' options(op)
26
##' @method ascii lm
37
ascii.lm <- function (x, include.rownames = TRUE, include.colnames = TRUE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = TRUE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...){
48
x <- as.data.frame(summary(x)$coef)
@@ -20,6 +24,10 @@ ascii.lm <- function (x, include.rownames = TRUE, include.colnames = TRUE, rowna
2024
}
2125

2226
##' @export
27+
##' @examples
28+
##' op <- options(asciiType = "org")
29+
##' local({x <- 1:10; y <- rnorm(length(x), 1+x); ascii(summary(lm(y~x))) })
30+
##' options(op)
2331
##' @method ascii summary.lm
2432
ascii.summary.lm <- function (x, include.rownames = TRUE, include.colnames = TRUE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = TRUE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...){
2533
x <- as.data.frame(x$coef)

R/asciiMatrix.r

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
##' @export
2+
##' @examples
3+
##' op <- options(asciiType = "org")
4+
##' ascii(matrix(1:4,2,2,FALSE,list(1:2,c("A","B"))), TRUE, TRUE, digits=0)
5+
##' options(op)
26
##' @method ascii matrix
37
ascii.matrix <- function (x, include.rownames = FALSE, include.colnames = FALSE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = FALSE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...){
48

R/asciiTable.r

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
##' @export
2+
##' @examples
3+
##' op <- options(asciiType = "org")
4+
##' ascii(table(rbinom(100,5,.3)), digits=0)
5+
##' options(op)
26
##' @method ascii table
37
ascii.table <- function (x, include.rownames = TRUE, include.colnames = TRUE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = TRUE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...){
48

R/asciiVector.r

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
##' @export
2+
##' @examples
3+
##' op <- options(asciiType = "org")
4+
##' ascii(c(a=1L,b=2L),FALSE,TRUE,digits=0)
5+
##' options(op)
26
##' @method ascii integer
37
ascii.integer <- function (x, include.rownames = FALSE, include.colnames = FALSE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = FALSE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...){
48
obj <- asciiTable$new(x = x, include.rownames = include.rownames,
@@ -19,6 +23,10 @@ ascii.integer <- function (x, include.rownames = FALSE, include.colnames = FALSE
1923
}
2024

2125
##' @export
26+
##' @examples
27+
##' op <- options(asciiType = "org")
28+
##' ascii(seq(0,1,length=11),digits=1)
29+
##' options(op)
2230
##' @method ascii numeric
2331
ascii.numeric <- function (x, include.rownames = FALSE, include.colnames = FALSE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = FALSE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...){
2432
obj <- asciiTable$new(x = x, include.rownames = include.rownames,
@@ -39,6 +47,10 @@ ascii.numeric <- function (x, include.rownames = FALSE, include.colnames = FALSE
3947
}
4048

4149
##' @export
50+
##' @examples
51+
##' op <- options(asciiType = "org")
52+
##' ascii(c(a="A",b="B"),FALSE,TRUE,header=TRUE)
53+
##' options(op)
4254
##' @method ascii character
4355
ascii.character <- function (x, include.rownames = FALSE, include.colnames = FALSE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = FALSE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...){
4456
obj <- asciiTable$new(x = x, include.rownames = include.rownames,
@@ -59,6 +71,10 @@ ascii.character <- function (x, include.rownames = FALSE, include.colnames = FAL
5971
}
6072

6173
##' @export
74+
##' @examples
75+
##' op <- options(asciiType = "org")
76+
##' ascii(factor(c("A","B")),FALSE)
77+
##' options(op)
6278
##' @method ascii factor
6379
ascii.factor <- function (x, include.rownames = FALSE, include.colnames = FALSE, rownames = NULL, colnames = NULL, format = "f", digits = 2, decimal.mark = ".", na.print = "", caption = NULL, caption.level = NULL, width = 0, frame = NULL, grid = NULL, valign = NULL, header = FALSE, footer = FALSE, align = NULL, col.width = 1, style = NULL, tgroup = NULL, n.tgroup = NULL, talign = "c", tvalign = "middle", tstyle = "h", bgroup = NULL, n.bgroup = NULL, balign = "c", bvalign = "middle", bstyle = "h", lgroup = NULL, n.lgroup = NULL, lalign = "c", lvalign = "middle", lstyle = "h", rgroup = NULL, n.rgroup = NULL, ralign = "c", rvalign = "middle", rstyle = "h", ...){
6480
obj <- asciiTable$new(x = x, include.rownames = include.rownames,

R/export.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ print.fig <- function(x, backend = getOption("asciiBackend"), ...) {
546546
##' @author David Hajage
547547
##' @examples
548548
##' \dontrun{
549-
##' old <- options(asciiType = "asciidoc")
549+
##' op <- options(asciiType = "asciidoc")
550550
##' createreport(head(esoph))
551551
##'
552552
##' r <- Report$new(author = "David Hajage", email = "dhajage at gmail dot com")
@@ -569,7 +569,7 @@ print.fig <- function(x, backend = getOption("asciiBackend"), ...) {
569569
##' r$create()
570570
##'
571571
##' r$create(backend = "markdown2pdf", format = "pdf")
572-
##' options(old)
572+
##' options(op)
573573
##' }
574574
createreport <- function(..., list = NULL, file = NULL, format = NULL, open = TRUE, backend = getOption("asciiBackend"), encoding = NULL, options = NULL, cygwin = FALSE, title = NULL, author = NULL, email = NULL, date = NULL) {
575575

0 commit comments

Comments
 (0)