Description Usage Arguments Details Value See Also Examples
Append a double or vector of doubles onto a mongo.bson.buffer.
1 | mongo.bson.buffer.append.complex(buf, name, value)
|
buf |
(mongo.bson.buffer) The buffer object to which to append. |
name |
(string) The name (key) of the field appended to the buffer. |
value |
(complex vector) The values(s) to append to the buffer. If value has a If value has a names attribute, a subobject is appended and the subfields are given the indicated names. Otherwise, if more than one element is present in value, the values are appended as a subarray. In the last case, a single complex is appended as the value of the field. |
Note that since BSON has no built-in complex type, R's complex values are appended as subobjects with two fields: "r" : the real part and "i" : the imaginary part.
TRUE if successful; otherwise, FALSE if an error occured appending the data.
mongo.bson,
mongo.bson.buffer,
mongo.bson.buffer.append
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append.complex(buf, "Alpha", 3.14159 + 2i)
b <- mongo.bson.from.buffer(buf)
# The above produces a BSON object of the form:
# { "Alpha" : { "r" : 3.14159, "i" : 2 } }
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append.complex(buf, "complexi", c(1.7 + 2.1i, 97.2))
b <- mongo.bson.from.buffer(buf)
# The above produces a BSON object of the form:
# { "complexi" : [ { "r": 1.7, i : 2.1}, { "r": 97.2, "i" : 0} ] }
buf <- mongo.bson.buffer.create()
values <- c(0.5 + 0.1i, 0.25)
names(values) <- c("Theta", "Epsilon")
mongo.bson.buffer.append.complex(buf, "Values", values)
b <- mongo.bson.from.buffer(buf)
# The above produces a BSON object of the form:
# { "Values" : { "Theta" : { "r" : 0.5, "i" : 0.1 },
# "Epsilon" : { " r" : 0.25, "i" : 0 } } }
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.