Differences with R



ztsdb array types can be persisted to disk. See the reference section Durability and the discussion about persistence in the reference section Arrays of the reference document.


ztsdb arrays can be locked for copying. See run section Locking.

New types

connection, timer, zts are new types in ztsdb.

Type limitations in R

In ztsdb, nanoduration, nanoperiod, nanoival, nanotime are array types. zts is a combined type with a nanotime index and double data part. These types are true arrays; they are n-dimensional and have array indexing semantics, etc..

This is not the case in R for non-base types; due to limitations in R, the types nanoduration, nanoperiod, nanoival, nanotime are vectors and cannot be used in matrices or arrays. Similarly zts maps to a data.table with a first column of nanotime type and the subsequent columsn with type numeric. Here again R is not able to represent n-dimensionality.


ztsdb does not have NA. All values of nanoduration, nanoperiod, nanoival, nanotime, character and logical are valid. double has NaN, but not NA. The NaN semantic is that of the CPU's floating point unit.

Type conversion

Since any object may be permanent and potentially very large, ztsdb does not allow a type conversion that modifies the type of the object on the left hand side.

### in R
a <- c(1,2,3,4)
a[3] <- "a"       # a is now the character array [1] "1" "2" "a" "4"

### in ztsdb
a <- c(1,2,3,4)
a[3] <- "a"       # Error: conversion not defined for string to double

But type conversions that do not modify the target work like in R:

a <- c("a","b","c","d")
a[3] <- 20        # character array, 20 becomes a string: [1] "a"  "b"  "20" "d" 


Functions and scoping



Control structures