Hi there,
I'm trying to add functionality to the package Mice.jl to allow objects to be converted into the equivalent from the R package mice. I made an extension for this.
This works fine when trying to export the Julia object into R using @rput:
using Pkg
Pkg.add(url = "https://github.com/tom-metherell/Mice.jl.git")
using DataFrames, Mice, Random, RCall
df = DataFrame(
a = Vector{Union{Missing, Int}}(randperm(20)),
b = Vector{Union{Missing, Float64}}(randperm(20)),
c = Vector{Union{Missing, String}}(rand(["a", "b", "c"], 20)),
d = Vector{Union{Missing, Bool}}(rand(Bool, 20))
)
for col in axes(df, 2)
df[rand(1:20, 1), col] .= missing
end
imputedData = mice(df, m = 1, iter = 1)
@rput imputedData
However, when I am working from R and try to retrieve the Julia object using julia_eval, I get an error:
library(JuliaCall)
julia_setup()
julia_command('Pkg.add(url = "https://github.com/tom-metherell/Mice.jl.git")')
julia_library("DataFrames")
julia_library("Mice")
julia_library("Random")
julia_library("RCall")
julia_command('df = DataFrame(a = Vector{Union{Missing, Int}}(randperm(20)), b = Vector{Union{Missing, Float64}}(randperm(20)), c = Vector{Union{Missing, String}}(rand(["a", "b", "c"], 20)), d = Vector{Union{Missing, Bool}}(rand(Bool, 20)))')
julia_command("for col in axes(df, 2); df[rand(1:20, 1), col] .= missing; end")
julia_command("imputedData = mice(df, m = 1, iter = 1)")
julia_eval("imputedData")
Error in .julia$do.call_(jcall) :
invalid first argument, must be vector (list or atomic)
Do you have any idea how I might be able to fix this? I'm a bit confused as to why everything works okay if I start in Julia, but if I start in R I get this error, even though I'm trying to convert an object from Julia to R in both cases.
Many thanks!
Hi there,
I'm trying to add functionality to the package
Mice.jlto allow objects to be converted into the equivalent from the R packagemice. I made an extension for this.This works fine when trying to export the Julia object into R using
@rput:However, when I am working from R and try to retrieve the Julia object using
julia_eval, I get an error:Error in .julia$do.call_(jcall) :invalid first argument, must be vector (list or atomic)Do you have any idea how I might be able to fix this? I'm a bit confused as to why everything works okay if I start in Julia, but if I start in R I get this error, even though I'm trying to convert an object from Julia to R in both cases.
Many thanks!