[graalvm-users] No NA

Stepan stepan.sindelar at oracle.com
Mon Jul 30 07:50:16 PDT 2018


Hi Rodrigo,

 > There seems to be no way to get an NA from R.  Getting false back 
hides the fact the data is missing.

yes. We've updated the inteop behavior in the meantime. The example you 
provided gives different results in the new development version where 
FastR always gives R vectors via interop and the way to get to the 
elements is via sending the READ message, which is typically done with 
array subscript in most languages.

So if you access "NA" with either plain "NA" or "c(NA)" in either case 
you get back something that looks like an array of length 1, and if you 
access the element, you get back something that looks like nil in Ruby 
(responds with true to the IS_NULL message).

val = Polyglot.eval("R", "NA")
p val[0].nil?
# true

val = Polyglot.eval("R", "c(NA)")
p val[0].nil?
# true

vec = Polyglot.eval("R", "c(NA, 42)")
p vec[0].nil?
p vec[1]
# true
# 42

Note the last output is "42", not "[42]" because by using array 
subscript on an atomic vector, you get back the atomic values.

Cheers,
Stepan



More information about the GraalVM-Users mailing list