readOrg: Read Org Tables

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

Description

Read an Org table from a file.

Usage

1
2
3
4
readOrg(file, header = TRUE, dec = ".", comment.char = "",
        encoding = "", strip.white = TRUE,
        stringsAsFactors = FALSE,
        table.name = NULL, ...)

Arguments

file

character

header

logical

dec

character

comment.char

character

encoding

the encoding of the file

strip.white

logical

stringsAsFactors

logical; note that the default FALSE differs from read.csv

table.name

character: the name of the table to read (a regular expression)

...

further arguments

Details

When header is TRUE, readOrg will read the first 10 lines of the file (or the table, when table.name is specified) and try to find an org table header. Formating instructions such as <5> are discarded. Then the function uses read.csv to read the remainder of the file/table.

When table.name is specified, the function looks for a line that starts with #+NAME: <table.name> and reads the table that follows that line.

For empty files, readOrg behaves like read.csv: when completely empty, it fails; when headers are found, a zero-row data.frame is returned.

Value

A data.frame.

Author(s)

Enrico Schumann

References

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

See Also

read.csv

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
## create an Org file with a table and read the table
tmp <-
"#+TITLE: A Table

Next comes a table.

#+name: test_table
| a | b |
|---+---|
| 1 | 2 |
| 3 | 4 |

That was a table.
"

fname <- tempfile("testfile", fileext = ".org")
writeLines(tmp, fname)

require("org")
readOrg(fname, table.name = "test_table")

## End(Not run)

Example output

Loading required package: org
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called 'org'
  a b
1 1 2
2 3 4

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