Interfaces/R/Rserver/Quirks

From J Wiki
< Interfaces‎ | R
Jump to navigation Jump to search
Rserver | Methods | Formats | Examples | Quirks

Quirks

Some R and Rserver quirks are:

  • There are no scalars, for example a single number is treated as a 1-element list. Where possible, the J/Rserver interface returns 1-element lists as scalars.
  • a character string is a single thing, not a list of characters. Thus it is more like a J boxed character string. In R, you cannot create the J equivalent of 2 3 $ 'abc' - a direct attempt to do so would create 2 3 $ <'abc', while working with the individual characters would create 2 3 $ ,each 'abcdef' - since each "character" is treated as a 1-element list.
  • R indexing is in origin 1.
  • R arrays are in column-major order, and the J/Rserve interface preserves this order. This is not quite the transpose of J; for example, a 2x3x4 array in R has 4 blocks, each 2x3, so is equivalent to a 4x2x3 array in J. See Array Shape in Examples.
  • the Rserver interface will read data attributes, but not write them. The Rset verb will send dim (i.e. shape) in a separate command, while other attributes have to be sent explicitly.

Booleans

An R boolean has values FALSE (0), TRUE (1) and NA (2). Arithmetic can be done with TRUE and FALSE, while NA returns NA, for example:

> 1 + c(FALSE,TRUE,NA)
[1]  1  2 NA

A read of an R boolean returns a list of 0 1 and 2.

Writes to R booleans are not yet supported.

NULL

R has a NULL value. In the addon, this is represented as the string 'NULL'.

Not Yet Supported

  • Rset cannot yet assign a complex value