influxdata / influxdb-r

R library for InfluxDB
MIT License
43 stars 22 forks source link

Missing value in the JSON answer are dropped when converted into the R structure #4

Open svernede opened 9 years ago

svernede commented 9 years ago

a JSON respose

"[{"name":"serie1","columns":["time","sequence_number","value","flag"],"points":[[1414771113,14039930001,16,null],[1414770813,14039940001,17,"ok"],[1414770513,14039950001,18,"nok"]]}]"

is currently transformed in to the R structure

$serie1
        time sequence_number value flag
1 1414771113     14039930001  16.0    "ok"
2 1414770813     14039940001  17.8    "nok"
3 1414770513     14039950001  16.0    "ok"

Which is obviously not the expected answer.

In the conversion to the R data frame the JSON null value are dropped and the remaining values are recycled to match the other vector length. The correct handling of missing value in R should be done with NA

martin-magakian commented 9 years ago

I really beleave we should use "RJSONIO" instead of "rjson" It is faster, more flexible and handle null value.

That's what I do in my pull request https://github.com/influxdb/influxdb-r/pull/5 Commit https://github.com/martin-magakian/influxdb-r/commit/0aa5a652a02c0cc745dc7ed08d5c86ce52c7e4c1