stefan-m-lenz / JuliaConnectoR

A functionally oriented interface for calling Julia from R
Other
100 stars 6 forks source link

Relative path to source file #20

Closed wleoncio closed 1 year ago

wleoncio commented 1 year ago

If I have some Julia functions stored in a module.jl file, this is what I do to import them in R:

juliaCall("include", "/full/path/to/module.jl")
ju <- juliaImport(".myModule")

If this was part of a package, I know I could use system.file() to get the path to the module, but otherwise it's annoying (and unportable) to have to provide the full path to juliaCall().

Is there another solution to passing the relative path to module.jl?

stefan-m-lenz commented 1 year ago

In R you can use the normalizePath function to get the full path of a file. If the module file is in your R project, you can simply write:

juliaCall("include", normalizePath("module.jl"))

I would recommend this.

wleoncio commented 1 year ago

Thanks! I saw the usage of normalizePath() on your paper, but I ignored it since I assumed this function only served to replace "\" with "/" on Windows path strings. Your code works as expected, cheers!