as.orgtable: Prepare a matrix or data.frame to be used as an org-mode...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/as.orgfile.R

Description

Prepare a matrix or data.frame to be used as an org-mode table. Column names are required. Row names are optional (and default to FALSE

Usage

1

Arguments

x

Matrix or data.frame.

rownames

Logical. When FALSE (the default), the row.names are not displayed in the value. When TRUE, the row.names are displayed in the value. See the last example for details on this behavior.

Value

Vector of character strings, one item for each row of the argument x. The strings contain the markup that will make them appear as tables in an org-mode document.

Author(s)

Nooreen Dabbish <nerd@temple.edu> and Richard M. Heiberger <rmh@temple.edu>

See Also

microplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
tmp <- matrix(1:12, 3, 4, dimnames=list(letters[1:3], LETTERS[4:7]))
tmp
as.orgtable(tmp)
as.orgtable(tmp, rownames=TRUE)

tmpdf <- data.frame(tmp)
tmpdf
cat(as.orgtable(tmpdf), sep="\n")
cat(as.orgtable(tmpdf, rownames=TRUE), sep="\n")

## This example shows why row names default to FALSE.

tmp2 <- rbind(tmp, tmp)
tmp2
tmp2df <- data.frame(tmp2)
tmp2df

tmp2df <- cbind(" "=row.names(tmp2), group=rep(c("A","B"), each=3), tmp2df)
tmp2df

cat(as.orgtable(tmp2df), sep="\n")  ## this is what we want

## this has the unwanted initial column of 1:6
cat(as.orgtable(tmp2df, rownames=TRUE), sep="\n")

microplot documentation built on Nov. 29, 2020, 1:07 a.m.