<div dir="ltr"><div>Hello,</div><div><br></div><div>Thanks for all the answers. It just did a bunch of test and it seems to me now to either be a bug in Gnu R or just a very strange behavior that I don&#39;t understand either about R.  I will report it to the Gnu R user groups and see what they tell me.  The important point here is that Graalvm is doing exactly the same as Gnu R.</div><div><br></div><div>For the curious, here what happens in GNU R. Bellow, two examples. The only difference between the two is that I commented a &#39;print&#39; on the second code:</div><div><br></div><div>Example 1:</div><div><br></div><div>&gt; vect = c(1, 2, 3, 4, 5, 6);<br>&gt; nams = c(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;);<br>&gt; `names&lt;-`(vect, nams);<br>a b c d e f <br>1 2 3 4 5 6 <br>&gt; print(vect);<br>a b c d e f <br>1 2 3 4 5 6 <br>&gt; dims = c(3, 2);<br>&gt; `dim&lt;-`(vect, dims);<br>     [,1] [,2]<br>[1,]    1    4<br>[2,]    2    5<br>[3,]    3    6<br>&gt; print(vect);<br>a b c d e f <br>1 2 3 4 5 6 <br><br></div><div>As we can see, the vect at the end does not have the dimension property.</div><div><br></div><div>Example 2</div><div><br></div><div>&gt; vect = c(1, 2, 3, 4, 5, 6);<br>&gt; nams = c(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;);<br>&gt; `names&lt;-`(vect, nams);<br>a b c d e f <br>1 2 3 4 5 6 <br>&gt; # print(vect);<br>&gt; dims = c(3, 2);<br>&gt; `dim&lt;-`(vect, dims);<br>     [,1] [,2]<br>[1,]    1    4<br>[2,]    2    5<br>[3,]    3    6<br>&gt; print(vect);<br>     [,1] [,2]<br>[1,]    1    4<br>[2,]    2    5<br>[3,]    3    6<br></div><div><br></div><div>In this example, the first &#39;print(vect)&#39; is commented out.  When printing vect on the last line, the dimension is set.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 6, 2018 at 7:03 PM Benoit Daloze &lt;<a href="mailto:eregontp@gmail.com" target="_blank">eregontp@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It seems to me it&#39;s as Stepan said.<br>
R of course does not reassign Ruby variables.<br>
And most R operations might or not mutate the receiver in place, with<br>
the general model of mutating only if it&#39;s unobservable<br>
(it is observable here, `vec` is actually a second reference to the<br>
initial vector).<br>
<br>
On Fri, Jul 6, 2018 at 11:31 PM, Chris Seaton &lt;<a href="mailto:chris.seaton@oracle.com" target="_blank">chris.seaton@oracle.com</a>&gt; wrote:<br>
&gt; Maybe this is something to do with the `dim&lt;-` method? I don’t know anything about R but I guess that’s called when you do `names(something) =`. Can you try making a simple test case that just tests that these kind of methods can be called correctly? Maybe something about it messes up the arguments?<br>
&gt;<br>
&gt; Chris<br>
&gt;<br>
&gt;&gt; On 6 Jul 2018, at 17:41, Rodrigo Botafogo &lt;<a href="mailto:rodrigo.a.botafogo@gmail.com" target="_blank">rodrigo.a.botafogo@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hello,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;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.<br>
&gt;&gt;<br>
&gt;&gt; Here what I&#39;m trying in R:<br>
&gt;&gt;<br>
&gt;&gt; R.eval(&lt;&lt;-R)<br>
&gt;&gt;   vect = c(1, 2, 3, 4, 5, 6);<br>
&gt;&gt;   names(vect) = c(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;);<br>
&gt;&gt;   print(vect);<br>
&gt;&gt;   dim(vect) = c(3, 2);<br>
&gt;&gt;   print(vect)<br>
&gt;&gt; R<br>
&gt;&gt;<br>
&gt;&gt; The first print show the names set:<br>
&gt;&gt;<br>
&gt;&gt; a b c d e f<br>
&gt;&gt; 1 2 3 4 5 6<br>
&gt;&gt;<br>
&gt;&gt; and the second print shows the dimension change.  Changing the &quot;dim&quot;<br>
&gt;&gt; attribute erases the names attribute:<br>
&gt;&gt;      [,1] [,2]<br>
&gt;&gt; [1,]    1    4<br>
&gt;&gt; [2,]    2    5<br>
&gt;&gt; [3,]    3    6<br>
&gt;&gt;<br>
&gt;&gt; Now, doing this using interop:<br>
&gt;&gt;<br>
&gt;&gt; # pp to allow printing: already reported bug<br>
&gt;&gt; pp = Polyglot.eval(&quot;R&quot;, &quot;function(x) print(x)&quot;)<br>
&gt;&gt;<br>
&gt;&gt; vec = Polyglot.eval(&quot;R&quot;, &quot;c&quot;).call(1, 2, 3, 4, 5, 6)<br>
&gt;&gt; nams = Polyglot.eval(&quot;R&quot;, &quot;c&quot;).call(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;)<br>
&gt;&gt; Polyglot.eval(&quot;R&quot;, &quot;`names&lt;-`&quot;).call(vec, nams)<br>
&gt;&gt; pp.call(vec)<br>
&gt;&gt;<br>
&gt;&gt; this prints as expected the vector with the names attribute:<br>
&gt;&gt;<br>
&gt;&gt; a b c d e f<br>
&gt;&gt; 1 2 3 4 5 6<br>
&gt;&gt;<br>
&gt;&gt; dims = Polyglot.eval(&quot;R&quot;, &quot;c&quot;).call(3, 2)<br>
&gt;&gt; Polyglot.eval(&quot;R&quot;, &quot;`dim&lt;-`&quot;).call(vec, dims)<br>
&gt;&gt; pp.call(vec)<br>
&gt;&gt;<br>
&gt;&gt; a b c d e f<br>
&gt;&gt; 1 2 3 4 5 6<br>
&gt;&gt;<br>
&gt;&gt; method dim&lt;- does not seem to  have worked.  There is no error message or anything after calling `dim&lt;-`<br>
&gt;&gt;<br>
&gt;&gt; Is this a bug or did I do something wrong here?  Its strange that some attributes work and others don&#39;t.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Rodrigo Botafogo<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; GraalVM-Users mailing list<br>
&gt;&gt; <a href="mailto:GraalVM-Users@oss.oracle.com" target="_blank">GraalVM-Users@oss.oracle.com</a><br>
&gt;&gt; <a href="https://oss.oracle.com/mailman/listinfo/graalvm-users" rel="noreferrer" target="_blank">https://oss.oracle.com/mailman/listinfo/graalvm-users</a><br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; GraalVM-Users mailing list<br>
&gt; <a href="mailto:GraalVM-Users@oss.oracle.com" target="_blank">GraalVM-Users@oss.oracle.com</a><br>
&gt; <a href="https://oss.oracle.com/mailman/listinfo/graalvm-users" rel="noreferrer" target="_blank">https://oss.oracle.com/mailman/listinfo/graalvm-users</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="m_7962678476861815015gmail_signature" data-smartmail="gmail_signature">Rodrigo Botafogo<br>Integrando TI ao seu negócio<br>21-3010-4802/11-3010-1802</div>