By Kevin Bonham
The data used in this video was generated with dummy_data.jl,
and is in the tarball dummy_data.tar.gz.
The notebook that forms the basis of this tutorial series
is in longitudinal-analysis.rmd
VS Code extensions installed
Julia packages used
Julia commands
]to enter the Pkg REPL (eg to add packages)- press backspace to go back to the regular REPL
activate .to activate the current directory as a Julia environmentstto show the status (eg which packages are installed)add SomePackageto add a package to your environmentrm SomePackageto remove a package from your environmentinstantiateif you have a Project.toml, and want to install all the packages in it (to eg reproduce an environment)
using SomePackageto load a package
Once you have CondaPkg.jl installed,
and have run conda install r-base in the Pkg REPL,
you can link this installation to VS Code by updating the following parameters
in your environment settings (.vscode/settings.json):
{
"r.libPaths": [
".CondaPkg/.pixi/envs/default/lib/R"
],
"r.rpath.linux": ".CondaPkg/.pixi/envs/default/bin/R",
"r.rterm.linux": ".CondaPkg/.pixi/envs/default/bin/R"
}Set RCall library path
In the Julia REPL, run:
julia> ENV["R_HOME"] = joinpath(".CondaPkg", ".pixi", "envs", "default", "lib", "R")
julia> using Pkg; Pkg.build("RCall") # or '] build RCall'RegEx magic to convert code cells from R to Julia
In VS Code, you can use the following regex to convert R code cells to Julia:
Capture:
```\{r(.+?)\}\n([\s\S]*?)```Replace:
```{julia$1}\nR"""\n$2"""\n```R code to display a plot
p <- # platting code...
png("plot1.png")
print(p)
dev.off()Using Julia to display a plot
- Add the packages
Images.jlandFileIO.jl
using Pkg
Pkg.add("Images") #or `] add Images`
Pkg.add("FileIO") #or `] add FileIO`- Use the following code to display a plot:
using Images, FileIO
load("plot1.png")Load dataframe from a CSV file
using CSV, DataFrames
jsubjects = CSV.read("dummy_subjects.csv", DataFrame)Left join two dataframes
leftjoin(samples, subjects; on="subject"=>"subject_id")