Search code examples
rjuliarcall

Import data vector from julia to R using RCall


Assume I have a Julia data array like this:

Any[Any[1,missing], Any[2,5], Any[3,6]]

I want to import it to R using RCall so I have an output equivalent to this:

data <- cbind(c(1,NA), c(2,5), c(3,6))

Note: the length of data is dynamic and it may be not 3!

could anyone help me how can I do this? Thank you


Solution

  • You can just interpolate a matrix into R:

    a = [ 1    2  3
       missing 5  6 ]
    R"data <- $a"
    

    To reorgnize your "array of array" into a matrix, you need to concat them

    b = Any[Any[1,missing], Any[2,5], Any[3,6]]
    a = hcat(b...)
    R"data <- $a"