Description Usage Arguments Details Value Examples
Convert data to InfluxDB line protocol
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | line_protocol(data, measurement, tag = NULL, field = NULL,
time = NULL, chk_escape = FALSE, chk_na = FALSE, use_int = FALSE,
fp_prec = NULL, epoch = c("ns", "u", "ms", "s", "m", "h"))
line_protocol_gen(ref, measurement, tag = NULL, field = NULL,
time = NULL, chk_escape = FALSE, chk_na = FALSE, use_int = FALSE,
fp_prec = NULL, epoch = c("ns", "u", "ms", "s", "m", "h"))
## Default S3 method:
line_protocol_gen(ref, measurement, tag = NULL,
field = NULL, time = NULL, chk_escape = FALSE, chk_na = FALSE,
use_int = FALSE, fp_prec = NULL, epoch = c("ns", "u", "ms", "s",
"m", "h"))
## S3 method for class 'xts'
line_protocol_gen(ref, measurement, tag = NULL,
field = NULL, time = NULL, chk_escape = FALSE, chk_na = FALSE,
use_int = FALSE, fp_prec = NULL, epoch = c("ns", "u", "ms", "s",
"m", "h"))
|
data |
data to convert. |
measurement |
measurement name, or column name of measurement in ref |
tag |
column names of tags in ref |
field |
column names of fields in ref, if NULL, all columns will be used as fields |
time |
column name of time in ref |
chk_escape |
whether to check special characters to escape |
chk_na |
whether to check NA values |
use_int |
whether to use integer data type |
fp_prec |
precision of floating point data, if NULL, system default is used |
epoch |
unit of epoch |
ref |
a reference data structure |
line_protocol() converts a named data structure to a character vector of InfluxDB line protocol. It is a wrapper of line_protocol_gen(), which parses reference data and returns a converter function that accepts same data structure.
Remarks on NA values. if chk_na is TURE, line_protocol_gen() checks for NA values in fields ONLY and uses regex ",(?:(?!,|=).)*?=NA" to match/remove NA fields. However this comes with two caveat: "=NA" inside string field values are replace by random token @_=_N_A@ + a random number and later replaced back to =NA, if you have such values and accidentally with same random token, Secondly, as you may notice, the mentioned regex can't distinguish field keys with special characters such as special\,key\=NA=100 will cause problem.
a function that accepts same data structure as ref, or a character vector of line protocol
1 2 3 4 5 | ref <- iris
f <- line_protocol_gen(ref, "iris", tag = "Species")
lp <- f(ref)
lp2 <- line_protocol(ref, "iris", tag = "Species")
stopifnot(all(lp == lp2))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.