Shout out to JuliaConnectoR and DataFrames.jl / Tables.jl

I’m impressed at how smoothly these two packages worked together for me just now!

I was creating a Julia to R interface for a little package I’m developing and noticed that the JuliaConnectoR package could directly translate julia tables to R dataframes with the as.data.frame() function.

Awesome, one problem: the data I wanted to send over was currently a Vector{myStruct} object. I thought it was going to take a long time to convert this to a DataFrame but this post shows that you literally just have to pass the object to DataFame (?!).

So in one line of julia code and one line of R code I was able to (1) convert a custom datatype collection to a dataframe, (2) migrate the data into a different language, and (3) convert that data into a native data type independent of julia. :exploding_head:

Here are the two lines in case anyone was curious:

#Julia
#Takes in a partially directed acyclic graph (PDAG)
#edges() creates an iterator over all the edges in the graph 
#DataFrame converts the edge iterator into a table

edgetable(g::PDAG) = DataFrame(edges(g))

FGES is the name of the package and g is an instance of the PDAG:

#R
#Convert the edge list to an R dataframe
df <- as.data.frame(FGES$edgetable(g))
7 Likes