You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that different classes of NA were treated differently on a round trip:
library(V8)
ct<- v8()
## Logical and character of length one return as NULLct$assign("na", NA)
ct$get("na")
#> NULLct$assign("na_char", NA_character_)
ct$get("na_char")
#> NULL## Real, integer, and complex return as "NA" stringct$assign("na_real", NA_real_)
ct$get("na_real")
#> [1] "NA"ct$assign("na_int", NA_integer_)
ct$get("na_int")
#> [1] "NA"ct$assign("na_complex", NA_complex_)
ct$get("na_complex")
#> [1] "NA"## When vector is greater than length 1, get vector of NAs back:ct$assign("nas", c(NA, NA))
ct$get("nas")
#> [1] NA NA
I then looked at other 'missing' types: NaN and NULL:
## NaN returns as "NaN" stringct$assign("nan", NaN)
ct$get("nan")
#> [1] "NaN"## NULL returns as an empty list()ct$assign("null_", NULL)
ct$get("null_")
#> named list()
I think the inconsistencies in the NA types is a bit of a problem, but not sure what you think about the NaN and NULL situations?
The text was updated successfully, but these errors were encountered:
ateucher
changed the title
Inconsistencies with NA and different types of 'missingness'
Inconsistencies with NA and other types of 'missingness'
Feb 3, 2018
Yeah the problem is that we currently use json to serialize the data, which does not support NA types. Maybe with the new V8 we can try a binary serialization format.
Yup, that makes sense for the NaN vs NULL vs NA cases... but I'm still surprised at the differences between NA_character_ and NA_real_ (for example), where the former is comes back as NULL, and the latter comes back as "NA" character string...
EDIT: Actually, this is perhaps better discussed in jsonlite:
# length onejsonlite::toJSON(NA_character_)
#> [null]jsonlite::toJSON(NA_real_)
#> ["NA"]# greater than length onejsonlite::toJSON(rep(NA_character_, 2))
#> [null,null]jsonlite::toJSON(rep(NA_real_, 2))
#> ["NA","NA"]# And coming back the other way:jsonlite::fromJSON('null')
#> NULLjsonlite::fromJSON('"NA"')
#> [1] "NA"jsonlite::fromJSON('[null,null]')
#> [1] NA NAjsonlite::fromJSON('["NA","NA"]')
#> [1] NA NA
I noticed that different classes of
NA
were treated differently on a round trip:I then looked at other 'missing' types:
NaN
andNULL
:I think the inconsistencies in the
NA
types is a bit of a problem, but not sure what you think about theNaN
andNULL
situations?The text was updated successfully, but these errors were encountered: