Getting started

library(basetable)

basetable provides a base-style front end for tabular work with a native C++ table engine. The core design goals are explicit semantics, compact naming, and equal support for nested calls and native |> pipelines.

The canonical compact core

Most workflows need only a small set of regular verbs:

Task Canonical functions
Inspect preview(), describe(), missingness()
Keep rows subset()
Keep or remove columns pick(), drop()
Create columns transform()
Order rows orderrows()
Summarise aggregate(), summaries(), count()
Join merge(), antimerge(), semimerge()
Reshape tolong(), towide()
Validate assertcomplete(), assertunique(), assertrows()

These are canonical names, not one layer of aliases among several grammars. Each function accepts a table as its first argument, uses character vectors for column specifications, and returns a bt_table. Those regular rules make pipelines compact for people and make function selection predictable for program-generating tools such as language models.

The package is intentionally focused on in-memory table manipulation, exploration, and validation. Read and write files with base R or a dedicated I/O package, then pass the resulting data frame to basetable. Domain-specific parsing and validation remain the responsibility of focused packages.

subset(mtcars, cyl == 6, select = c("mpg", "hp", "wt"))
## # basetable: 7 x 3
##    mpg  hp    wt
## 1 21.0 110 2.620
## 2 21.0 110 2.875
## 3 21.4 110 3.215
## 4 18.1 105 3.460
## 5 19.2 123 3.440
## 6 17.8 123 3.440
## 7 19.7 175 2.770
mtcars |>
  pick(c("mpg", "hp", "wt", "cyl")) |>
  aggregate(by = "cyl", value = c("mpg", "hp"), fun = mean)
## # basetable: 3 x 3
##   cyl      mpg        hp
## 1   4 26.66364  82.63636
## 2   6 19.74286 122.28571
## 3   8 15.10000 209.21429

Namespaces stay explicit

Compact names intentionally overlap with base R and other table packages. If more than one is attached, qualify the function rather than introducing a new alias or changing grammars mid-pipeline.

mtcars |>
  basetable::subset(cyl == 6) |>
  basetable::pick(c("mpg", "hp", "wt")) |>
  basetable::transform(power = hp / wt)
## # basetable: 7 x 4
##    mpg  hp    wt    power
## 1 21.0 110 2.620 41.98473
## 2 21.0 110 2.875 38.26087
## 3 21.4 110 3.215 34.21462
## 4 18.1 105 3.460 30.34682
## 5 19.2 123 3.440 35.75581
## 6 17.8 123 3.440 35.75581
## 7 19.7 175 2.770 63.17690