uot;
// [[Rcpp::export]]
RObject rcpp_factor(){
  IntegerVector v = {1,2,3,1,2,3};
  CharacterVector ch = {&quot;A&quot;,&quot;B&quot;,&quot;C&quot;};
  v.attr(&quot;class&quot;) = &quot;factor&quot;;
  v.attr(&quot;levels&quot;) = ch;
  return v;
}</code></pre>
<p>The execution result below, we can see that the integer vector returned to R is treated as <code>factor</code>.</p>
<pre><code>&gt; rcpp_factor()
[1] A B C A B C
Levels: A B C</code></pre>

</div>
            </section>

          </div>
        