Table Of Contents

7.14. R

7.14.1. Introduction

Warning

Our R API is currently in alpha release and is not recommended for production

This document is an introduction to the quasardb R API. It is primarily focused on timeseries, and will guide you through the various ways you can interact with the QuasarDB backend.

7.14.2. Requirements

7.14.3. Installation

On Unix-like systems, if you have quasardb C API installed system-wide, you can install quasardb R API directly from GitHub as follows:

if (!requireNamespace("devtools", quietly = TRUE)) {
  install.packages("devtools")
}
devtools::install_github("bureau14/qdb-api-r")

For instructions on how to perform a clean build of the extension from source, please look at our GitHub repository.

7.14.4. Usage

Require the R library, and verify the C API version:

library(quasardb)
version()
build()

Establishing a connection

Connect to a QuasarDB cluster:

handle <- connect("qdb://127.0.0.1:2836")

Creating a timeseries

ts_create(handle, name = "timeseries1",
          columns = c("column1" = ColumnType$Blob, "column2" = ColumnType$Double))

This will create a timeseries with the a default shard size of 24h.

Retrieving timeseries

QuasarDB allows you to organise many different timeseries by tag. To look up these timeseries by tag, use the query_find:

keys <- query_find(handle, "find(tag='nyse' and type=ts)")

Executing queries

You can execute queries directly in R and process their results:

result <- query_find(handle, "select first(open), max(high) from find(tag='nasdaq' and type=ts) in range(today, -1y) group by day")
arrow_backPrevious
7.13. Python
Next arrow_forward
7.15. Spark connector