# The Brass Tacks of Julia Programming – Part III

Articles From: QuantInsti
Website: QuantInsti

See Part I for instructions on basic arithmetic operations and Part II for working with matrices

## Using R and Python code in Julia

There can be times where you want to use your R or Python code as the libraries to perform certain operations may not be available in Julia.

However, using 2 languages to perform a certain operation can be a challenge. Hence, Julia provides an option to use R and Python code by using the “PyCall” and “RCall” packages.

### How to use Python code in Julia

Here’s how you can use your Python code in Julia.

``````
# Install the "PyCall" package for Python
using Pkg
using PyCall

## Importing numpy package from Python
np = pyimport("numpy")

## Using numpy package in Julia
np.array([1,2,3])``````
``````Output:

3-element Vector{Int64}:
1
2
3``````

### How to use R code in Julia

Let’s look at an example of using R in Julia.

``````# Install "RCall" package for R
using RCall

# There are several ways to call R code

# Method 1
# Calling the mean() function from R
rcall(:mean, [1,2,3])

# Method 2 for user-defined functions
R"""
power_4 <- function(x)
{
return(x^4)
}"""

## Calling the defined function
rcall(:power_4, 5)``````
``````Output:

RObject{RealSxp}
[1] 2
RObject{RealSxp}
[1] 625``````

For further details on using the RCall package, you can refer here.