Ott's Utility Functions

A growing collection of personal utility functions. Currently provides tools to parse Rich Text Format (RTF) files and extract their tables into data frames, automatically detecting header rows, merging multi-page tables, and resolving merged cells. Particularly useful for tables produced by SAS or by the 'r2rtf' package, which are commonly used for clinical trial and regulatory reporting.


otter

CRANstatus Lifecycle:stable Codecov testcoverage

otter is a small collection of functions that are useful for me, Ott, and hopefully for others too. Sharing is caring!

Currently otter provides rtf_to_df(), which parses RTF files and extracts embedded tables into a data frame. It automatically detects header rows, handles multi-page and multi-table RTF output, and supports non-UTF-8 encodings.

Installation

You can install the development version of otter from GitHub with:

# install.packages("pak")
pak::pak("ottvahtrik/otter")

Example

rtf_to_df() reads an RTF table and returns its contents as a data frame:

library(otter)

path <- system.file("extdata", "example.rtf", package = "otter")
rtf_to_df(path, include_header = TRUE)
#>    Name Value
#> 1 Alice    10
#> 2   Bob    20

If the RTF file contains multiple distinct tables, use table_index to select one of them:

multi_path <- system.file("extdata", "multi_table_example.rtf", package = "otter")
rtf_to_df(multi_path, include_header = TRUE, table_index = 2L)
#>   C D
#> 1 3 4

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("otter")

0.1.0 by Ott Vahtrik, a month ago


https://github.com/ottvahtrik/otter, https://ottvahtrik.github.io/otter/


Report a bug at https://github.com/ottvahtrik/otter/issues


Browse source code at https://github.com/cran/otter


Authors: Ott Vahtrik [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Suggests lintr, testthat


See at CRAN