[graalvm-users] Setting attributes inconsistencies
Rodrigo Botafogo
rodrigo.a.botafogo at gmail.com
Fri Jul 6 09:41:24 PDT 2018
Hello,
I'm trying to set attributes to an r object using interop. For some
attributes everything works fine and for others the attribute is not set.
Here what I'm trying in R:
R.eval(<<-R)
vect = c(1, 2, 3, 4, 5, 6);
names(vect) = c("a", "b", "c", "d", "e", "f");
print(vect);
dim(vect) = c(3, 2);
print(vect)
R
The first print show the names set:
a b c d e f
1 2 3 4 5 6
and the second print shows the dimension change. Changing the "dim"
attribute erases the names attribute:
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
Now, doing this using interop:
# pp to allow printing: already reported bug
pp = Polyglot.eval("R", "function(x) print(x)")
vec = Polyglot.eval("R", "c").call(1, 2, 3, 4, 5, 6)
nams = Polyglot.eval("R", "c").call("a", "b", "c", "d", "e", "f")
Polyglot.eval("R", "`names<-`").call(vec, nams)
pp.call(vec)
this prints as expected the vector with the names attribute:
a b c d e f
1 2 3 4 5 6
dims = Polyglot.eval("R", "c").call(3, 2)
Polyglot.eval("R", "`dim<-`").call(vec, dims)
pp.call(vec)
a b c d e f
1 2 3 4 5 6
method dim<- does not seem to have worked. There is no error message or
anything after calling `dim<-`
Is this a bug or did I do something wrong here? Its strange that some
attributes work and others don't.
--
Rodrigo Botafogo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://oss.oracle.com/pipermail/graalvm-users/attachments/20180706/037e53c4/attachment.html
More information about the GraalVM-Users
mailing list