Interface RValue
- All Known Implementing Classes:
RValue.Int, RValue.List, RValue.Logical, RValue.Null, RValue.Num, RValue.Other, RValue.Raw, RValue.Str
public sealed interface RValue
permits RValue.Null, RValue.Logical, RValue.Int, RValue.Num, RValue.Str, RValue.Raw, RValue.List, RValue.Other
An R object as Java data (a copy). Read with doubles(), ints(), strings(),
booleans(), bytes(), firstDouble(), firstString(), elements(), matrix() and
create with RValue.of(...), listOf(...), dataFrame(...), factor(...).
The types as records: The vector types of R map to one record each; the attributes names, dim, dimnames, class, levels and row.names are kept (other attributes are not transferred).
NA: R's own values are kept (integer and logical: NA_INTEGER, double:
the NA bit pattern, see isNA(double), character: null).
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordAn integer vector (also a factor: the codes with the attribute "levels").static final recordA list (also a data frame: class "data.frame" with names and row.names).static final recordA logical vector: 1 (TRUE), 0 (FALSE), NA_INTEGER (NA).static final recordNULL.static final recordA numeric (double) vector, a matrix with the attribute "dim".static final recordAn object which is not transferred (e.g., a function or an environment): only its type.static final recordA raw vector.static final recordA character vector (null is NA). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intNA of integer and logical vectors (as in R).static final doubleNA_real_ of R (a NaN with a payload, distinct from NaN).static final longThe bit pattern of NA_real_ in R.static final RValueNULL of R. -
Method Summary
Modifier and TypeMethodDescriptiondefault RValueThe attribute or null.The attributes (names, dim, dimnames, class, levels, row.names), never null.attributes(Object... nameValuePairs) Attributes with names and values (e.g., attributes("names", names)).default boolean[]booleans()The values as booleans: logical values (NA: false), numbers (not 0: true).default byte[]bytes()The bytes of a raw vector.static RValueA data frame: the columns (vectors of the same length) by name.default int[]dim()The dimensions (the "dim" attribute) or null.default double[]doubles()The values as numbers: numeric, integer and logical vectors (NA: NA_REAL), character vectors are parsed (not a number: NA_REAL).default RValueelement(int index) An element of a list (from 0).default RValueAn element of a list by name, or null.elements()The elements of a list (also the columns of a data frame).static RValueA factor: the labels (null: NA), the levels sorted as in R.default doubleThe first number (seedoubles()).default intfirstInt()The first integer (seeints()).default StringThe first text (seestrings()).default booleanReturns true if the "class" attribute contains the class.default int[]ints()The values as integers: integer and logical vectors, numbers are truncated (NA, NaN: NA_INTEGER).default booleanA character vector.default booleandefault booleanisFactor()default booleanisList()A list (also a data frame).default booleandefault booleanisMatrix()A matrix (two dimensions).static booleanisNA(double v) Returns true if a double is R's NA (not any NaN).default booleanisNull()default booleanNumbers: a numeric or an integer vector (not a factor).default booleanisRaw()default booleanisTrue()True if the first value is TRUE (a logical vector, e.g., of is.numeric(x)).intlength()The number of elements (0 for NULL).static RValueA list without names.static RValueA list with names (in the order of the map).default double[][]matrix()A matrix as rows: [row][column] (numbers with two dimensions).default String[]names()The names (the "names" attribute) or null.static RValueof(boolean... values) A logical vector.static RValueof(byte... values) A raw vector.static RValueof(double... values) A numeric vector.static RValueof(int... values) An integer vector.static RValueA character vector (null: NA).default String[]strings()The values as text: a character vector (NA: null), the labels of a factor, numbers and logical values as text (NA: "NA").default StringtypeName()The type of R, e.g., "double", "character", "list" (for messages).default RValueThis value with one attribute more (or replaced; null removes it).default RValuewithDim(int... dim) This value as a matrix or an array with the dimensions.default RValueThis value with names.
-
Field Details
-
NA_INTEGER
static final int NA_INTEGERNA of integer and logical vectors (as in R).- See Also:
-
NA_REAL_BITS
static final long NA_REAL_BITSThe bit pattern of NA_real_ in R.- See Also:
-
NA_REAL
static final double NA_REALNA_real_ of R (a NaN with a payload, distinct from NaN). -
NULL
NULL of R.
-
-
Method Details
-
isNA
static boolean isNA(double v) Returns true if a double is R's NA (not any NaN). -
attributes
-
length
int length()The number of elements (0 for NULL). -
attribute
-
names
The names (the "names" attribute) or null. -
dim
default int[] dim()The dimensions (the "dim" attribute) or null. -
inherits
Returns true if the "class" attribute contains the class. -
of
A numeric vector. -
of
An integer vector. -
of
-
of
A logical vector. -
of
A raw vector. -
listOf
-
listOf
-
dataFrame
-
factor
-
with
-
withNames
-
withDim
This value as a matrix or an array with the dimensions. -
isNull
default boolean isNull() -
isNumeric
default boolean isNumeric()Numbers: a numeric or an integer vector (not a factor). -
isCharacter
default boolean isCharacter()A character vector. -
isLogical
default boolean isLogical() -
isRaw
default boolean isRaw() -
isList
default boolean isList()A list (also a data frame). -
isFactor
default boolean isFactor() -
isDataFrame
default boolean isDataFrame() -
isMatrix
default boolean isMatrix()A matrix (two dimensions). -
typeName
The type of R, e.g., "double", "character", "list" (for messages). -
doubles
default double[] doubles()The values as numbers: numeric, integer and logical vectors (NA: NA_REAL), character vectors are parsed (not a number: NA_REAL). -
ints
default int[] ints()The values as integers: integer and logical vectors, numbers are truncated (NA, NaN: NA_INTEGER). -
strings
The values as text: a character vector (NA: null), the labels of a factor, numbers and logical values as text (NA: "NA"). -
booleans
default boolean[] booleans()The values as booleans: logical values (NA: false), numbers (not 0: true). -
bytes
default byte[] bytes()The bytes of a raw vector. -
firstDouble
default double firstDouble()The first number (seedoubles()). -
firstInt
default int firstInt()The first integer (seeints()). -
firstString
-
isTrue
default boolean isTrue()True if the first value is TRUE (a logical vector, e.g., of is.numeric(x)). -
elements
-
element
An element of a list (from 0). -
element
-
matrix
default double[][] matrix()A matrix as rows: [row][column] (numbers with two dimensions). -
attributes
-