toOrg: Generate Org-mode Markup

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/toOrg.R

Description

Transform R objects into Org-mode objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
toOrg(x, ...)

## S3 method for class 'org'
print(x, ...)

## S3 method for class 'data.frame'
toOrg(x, row.names = NULL, ...)

## S3 method for class 'Date'
toOrg(x, inactive = FALSE, ...)

## S3 method for class 'POSIXt'
toOrg(x, inactive = FALSE, ...)

Arguments

x

an object

row.names

NULL, logical or character. If TRUE, row.names of x are added as the first column, with column name "row.names". If a character string, the string is used as the column name. See Examples.

If NULL, row.names are added when they are not 1, 2, ... (i.e. row numbers).

If FALSE, row.names are not added.

inactive

logical: use inactive timestamps? See http://orgmode.org/manual/Creating-timestamps.html .

...

other arguments

Details

Transforms an object x into character vectors with Org markup. Most useful when x is a data.frame.

toOrg is meant for snippets of code, not for producing whole Org documents.

When you work with POSIXt, make sure that a potential timezone does not cause trouble: Org does not support timezones.

Value

A character vector, usually with class org. In some cases, class character is additionally attached.

To save it to a file, use writeLines.

Author(s)

Enrico Schumann

References

Org mode manual http://orgmode.org/manual/index.html

See Also

toLatex, as.orgtable

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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
toOrg(data.frame(a = 1:3, row.names = LETTERS[1:3]))
## =>  | row.names | a |
##     |-----------+---|
##     | A         | 1 |
##     | B         | 2 |
##     | C         | 3 |

toOrg(data.frame(a = 1:3))
## =>  | a |
##     |---|
##     | 1 |
##     | 2 |
##     | 3 |

toOrg(data.frame(a = 1:3), row.names = TRUE)
## =>  | row.names | a |
##     |-----------+---|
##     | 1         | 1 |
##     | 2         | 2 |
##     | 3         | 3 |


toOrg(data.frame(a = 1:5), row.names = "row numbers")
## =>  | row numbers | a |
##     |-------------+---|
##     | 1           | 1 |
##     | 2           | 2 |
##     | 3           | 3 |
##     | 4           | 4 |
##     | 5           | 5 |

## Not run: 
writeLines(toOrg(data.frame(a = 1:3)), "~/Desktop/my_table.org")
## End(Not run)

## Dates/Times
toOrg(as.Date("2015-01-01"))                   ## <2015-01-01 Thu>
toOrg(as.Date("2015-01-01"), inactive = TRUE)  ## [2015-01-01 Thu]
toOrg(Sys.time())                              ## <2017-03-20 Mon 13:23:18>

## Convert Org dates to Date

## see ?strptime: Each input string is processed as far as
##                necessary for the format specified: any
##                trailing characters are ignored.
d <- toOrg(as.Date("2015-01-01"))
as.Date(d, "<%Y-%m-%d")

orgutils documentation built on May 1, 2019, 8:03 p.m.