Differences with R


New types

connection, timer, duration, period, interval, time, zts are all new types in ztsdb.

duration, period, interval, time are array types. zts is a combined type with a time index and double data part.


ztsdb does not have NA. All values of duration, period, interval, time, 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" 


In ztsdb, time is integer based and handles nanosecond time. In R POSIXct is (unfortunately) floating point based. This means that various time offsets have different precision. In general though R is not able to express nanosecond precision and rounding errors occur.

This creates issues when importing time into R since the former is converted to POSIXct representation and truncation may occur. Warnings are generated, but this is not a satisfactory solution.


Functions and scoping



Control structures