Description Usage Arguments Value See Also Examples
Append a double or vector of doubles onto a mongo.bson.buffer.
1 | mongo.bson.buffer.append.double(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 |
(double 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 as.double is appended as the value of the field. |
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 24 25 26 | buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append.double(buf, "YearSeconds",
365.24219 * 24 * 60 * 60)
b <- mongo.bson.from.buffer(buf)
# The above produces a BSON object of the form:
# { "YearSeconds" : 31556925.2 }
buf <- mongo.bson.buffer.create()
mongo.bson.buffer.append.double(buf, "dbls",
c(1.7, 87654321.123, 12345678.321))
b <- mongo.bson.from.buffer(buf)
# The above produces a BSON object of the form:
# { "dbls" : [1.7, 87654321.123, 12345678.321] }
buf <- mongo.bson.buffer.create()
fractions <- c(0.5, 0.25, 0.333333)
names(fractions) <- c("Half", "Quarter", "Third")
mongo.bson.buffer.append.double(buf, "Fractions", fractions)
b <- mongo.bson.from.buffer(buf)
# The above produces a BSON object of the form:
# { "Fractions" : { "Half" : 0.5,
# "Quarter" : 0.25,
# "Third" : 0.333333 } }
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.