# Using RCall

**URL:** https://discourse.julialang.org/t/using-rcall/22714
**Category:** Statistics
**Created:** [April 3, 2019, 7:35pm UTC](https://discourse.julialang.org/t/using-rcall/22714 "2019-04-03T19:35:50Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Gunter\_Faes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunter_faes/32/12580_2.png) [@Gunter\_Faes](https://discourse.julialang.org/u/Gunter_Faes)
#### Post date: [April 3, 2019, 7:35pm UTC](https://discourse.julialang.org/t/using-rcall/22714/1 "2019-04-03T19:35:50Z")

</div>

Hello,

I’m still trying to solve my PCA problem, so I’m trying to use R over RCall. The package can be installed, but after using RCall, R reports up, but gets stuck! That is, nothing happens more…! The behavior applies to Julia 1.0.3 and Juliapro (Atom):

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

R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

```

That’s all, nothing’s happening anymore! The system is no longer responding…

I’m using Windows 10…

I am happy about every hint and many greetings,  
Günter

---

<div class="post-metadata">

### Author: ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)
#### Post date: [April 3, 2019, 10:12pm UTC](https://discourse.julialang.org/t/using-rcall/22714/2 "2019-04-03T22:12:07Z")

</div>

Using RCall doesn’t mean you will have a R repl right away. To call R code simply do

````julia
b = 100
@rput b
R"""
#R CODE HERE
a = sapply(1:b, function(x) x)
"""
@rget a;
a
```
````

---

<div class="post-metadata">

### Author: ![Gunter\_Faes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunter_faes/32/12580_2.png) [@Gunter\_Faes](https://discourse.julialang.org/u/Gunter_Faes)
#### Post date: [April 4, 2019, 6:37am UTC](https://discourse.julialang.org/t/using-rcall/22714/3 "2019-04-04T06:37:27Z")

</div>

Thank you for your answer! But that’s not what I mean.

I just can’t type anything anymore because the console or Atom is “frozen”. I wanted to run a similar example for testing, but I didn’t get that far! 🤔

Do you have any idea what that might be?

---

<div class="post-metadata">

### Author: ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)
#### Post date: [April 4, 2019, 7:46am UTC](https://discourse.julialang.org/t/using-rcall/22714/4 "2019-04-04T07:46:17Z")

</div>

What if you just do `using RCall` in the terminal? I am using Win10 also but I have R 3.5.3 and it works fine.

---

<div class="post-metadata">

### Author: ![Gunter\_Faes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunter_faes/32/12580_2.png) [@Gunter\_Faes](https://discourse.julialang.org/u/Gunter_Faes)
#### Post date: [April 4, 2019, 9:43am UTC](https://discourse.julialang.org/t/using-rcall/22714/5 "2019-04-04T09:43:57Z")

</div>

I had two R instances (3.4.3 and 3.5.2) installed. I uninstalled both and installed R 3.5.3. Now I get identical error messages for the terminal and for Juliapro:

```julia
ERROR: InitError: error compiling __init__ : error compiling initEmbeddedR: could not load library "C:\PROGRA~1\R\R-34~1.3\bin\x64\R.dll"

```

Is R 3.4.x preset in a setup file? Can I influence this and if so how? 🤔

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [April 4, 2019, 9:50am UTC](https://discourse.julialang.org/t/using-rcall/22714/6 "2019-04-04T09:50:47Z")

</div>

Not an Rcall user, but these types of DLL errors can often be solved by `] build RCall`

---

<div class="post-metadata">

### Author: ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)
#### Post date: [April 4, 2019, 9:53am UTC](https://discourse.julialang.org/t/using-rcall/22714/7 "2019-04-04T09:53:08Z")

</div>

Set your R\_HOME environment variable to C:\Program Files\R\R-3.5.2 or equivalent. then `]build RCall`

---

<div class="post-metadata">

### Author: ![Gunter\_Faes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunter_faes/32/12580_2.png) [@Gunter\_Faes](https://discourse.julialang.org/u/Gunter_Faes)
#### Post date: [April 4, 2019, 11:37am UTC](https://discourse.julialang.org/t/using-rcall/22714/8 "2019-04-04T11:37:58Z")

</div>

Hello both of you, thank you for this hint! It’s on!

First step:  
Activate the library setting of R from

```julia
# set a site library
# .Library.site <- file.path(chartr("\\", "/", R.home()), "site-library")

```

to

```julia
.Library.site <- file.path(chartr("\\", "/", R.home()), "site-library")

```

and then built! Then I could call and execute R as described in the documentation!

Thanks again and many greetings,  
Günter
