# Operation on an RObject{RealSxp} Created Using RCall

**URL:** <https://discourse.julialang.org/t/operation-on-an-robject-realsxp-created-using-rcall/50059>\
**Category:** General Usage\
**Created:** [November 12, 2020, 4:58pm UTC](https://discourse.julialang.org/t/operation-on-an-robject-realsxp-created-using-rcall/50059 "2020-11-12T16:58:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![atparedes](https://avatars.discourse-cdn.com/v4/letter/a/b5e925/32.png) [@atparedes](https://discourse.julialang.org/u/atparedes)\
**Post date:** [November 12, 2020, 4:58pm UTC](https://discourse.julialang.org/t/operation-on-an-robject-realsxp-created-using-rcall/50059/1 "2020-11-12T16:58:51Z")

</div>

Hello All,

New to Julia: I am using Julia to develop a large Monte Carlo simulation investigating the robustness of several statistical procedures. I created a couple of variables (vector) from the skew-normal distribution using RCall (using the package “sn”). Now, I am trying to select simple random samples from those vector (called X1 and X2) using several of the versions of the sample function and keep getting the following massage: **Sampler for this object is not defined** I haven’t been able to find a reference on how to work with RObjects in Julia, if one exits. Any feedback will be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Post date:** [November 12, 2020, 5:27pm UTC](https://discourse.julialang.org/t/operation-on-an-robject-realsxp-created-using-rcall/50059/2 "2020-11-12T17:27:45Z")

</div>

The `RObject` is only accessible in the R process that is started by `RCall`. Most of the time when using `RCall` you `rcopy` an object to the Julia session if you want to use it in Julia. For example

```julia
julia> using RCall
[Info: Precompiling RCall [6f49c342-dc21-5d91-9882-a32aef131414]

julia> R"rnorm(4)"
RObject{RealSxp}
[1] -0.3539573 -0.4693315 1.7016331 1.6902909

julia> v = rcopy(ans)
4-element Array{Float64,1}:
 -0.3539572923325208
 -0.46933145235119395
  1.7016330529402308
  1.6902908525686313

```

The first output is from R and is just showing what the vector looks like in R. Calling `rcopy(ans)` copies the R vector to a Vector in Julia.

In general you would wrap the expression to generate the vector in a call to `rcopy`, as in

```julia
julia> v1 = rcopy(R"runif(4)")
4-element Array{Float64,1}:
 0.6790683544240892
 0.377434688154608
 0.29283377691172063
 0.04867288493551314

```

I’m just showing it in two stages here to emphasize where the vectors reside.
