toOrg {orgutils} | R Documentation |
Generate Org-mode Markup
Description
Transform R objects into Org-mode objects.
Usage
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 |
If If |
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 https://orgmode.org/manual/index.html
See Also
toLatex
, function as.orgtable
in
microplot
Examples
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")