Skip to contents

Imports a documented table. A wrapper for read.table() that also reads associated yamlet metadata, if present, and applies it as attributes.

Usage

# S3 method for class 'character'
io_table(x, ext = getOption("yamlet_extension", ".yaml"), meta = NULL, ...)

Arguments

x

character file path; passed to read.table

ext

extension for metadata equivalent of x

meta

explicit file path for metadata

...

passed to read.table (if accepted) and to decorate

Value

data.frame

Examples

example(io_table)
#> 
#> io_tbl> # generate some decorated data
#> io_tbl> file <- system.file(package = 'yamlet', 'extdata','quinidine.csv')
#> 
#> io_tbl> x <- decorate(file)
#> 
#> io_tbl> # get a temporary filepath
#> io_tbl> out <- file.path(tempdir(), 'out.tab')
#> 
#> io_tbl> # save file using io_table (returns filepath)
#> io_tbl> foo <- io_table(x, out)
#> 
#> io_tbl> stopifnot(identical(out, foo))
#> 
#> io_tbl> # read using this filepath
#> io_tbl> y <- io_table(foo, as.is = TRUE)
#> 
#> io_tbl> # lossless round-trip
#> io_tbl> attr(x, 'source') <- NULL
#> 
#> io_tbl> rownames(x) <- NULL
#> 
#> io_tbl> rownames(y) <- NULL
#> 
#> io_tbl> stopifnot(identical(x, y))