Skip to contents

Creates a harbour_dtable from scratch, so a set of R data frames can be written out as a SeaTable base and imported.

Usage

hb_dtable(..., base_name = "harbouR base", collaborators = NULL)

Arguments

...

Named data frames, one per table.

base_name

Name recorded for the base.

collaborators

Optional list of collaborator records.

Value

A harbour_dtable, with the components hb_read_dtable() describes, holding one table per data frame.

Details

Column types are inferred: character becomes text, numeric number, logical checkbox, Date and POSIXct date, factor single-select with its levels as options, and a list-column of character vectors multiple-select with the values it uses as options. A list-column holding objects - file, image or location cells read from a live base - is flattened to text: a new base has none of the assets those cells point at.

A Date column, or a date-time column whose every value is midnight UTC - which is how hb_read_table() reads a date-only column - becomes a date column showing the date alone. Other date-times are written with their UTC offset, so the server stores the instant whatever zone it runs in.

A column named _id, such as the one hb_read_table() adds, is dropped: SeaTable keeps that name for the row identifier, and the new base has identifiers of its own. One that holds anything but SeaTable row ids is dropped with a harbour_warning_id_column warning.

New row ids, table ids, column keys and select-option ids are drawn from the session's random number generator, so building a base advances .Random.seed: a random draw made after hb_dtable() differs from the same draw made without it. Set the seed after building the base when an analysis needs its random numbers not to depend on it.

Examples

base <- hb_dtable(
  Samples = data.frame(Name = c("a", "b"), Value = c(1.5, 2.5)),
  base_name = "My base"
)
base
#> 
#> ── <harbour_dtable> ────────────────────────────────────────────────────────────
#> • base : "My base"
#> • tables : 1
#> • rows : 2
#> • assets : 0
#> 
#> - Samples (2 cols, 2 rows)

hb_read_table(base, "Samples")
#> # A tibble: 2 × 3
#>   Name  Value `_id`                 
#>   <chr> <dbl> <chr>                 
#> 1 a       1.5 Rf6-A--hQtiVKoYftEUIlQ
#> 2 b       2.5 _gmfdKEQQ7eVXoBFobKtQA