Description
Translate R Regression Model Formulae to 'Julia' Syntax.
Description
Metaprogramming utilities for converting R regression model formulae to equivalents in 'Julia' <doi:10.1137/141000671>, via modifications to the abstract syntax tree. Supports translations in zero correlation random effects syntax, protection of expressions to be evaluated as-is, interaction terms, and more. Accepts strings or R formula objects and returns modified R formula objects where possible (or a modified string, if not a valid formula in R).
README.md
JuliaFormulae
A utility package for converting R regression model formula to Julia GLM.jl and MixedModels.jl syntax.
See {jlme}
for an example application.
Installation
# install.packages("devtools")
devtools::install_github("yjunechoe/JuliaFormulae")
library(JuliaFormulae)
Supported conversions
Zero correlation:
julia_formula(y ~ x + (x || g)) #> y ~ x + zerocorr(x | g)
Protection:
julia_formula(y ~ x + I(x * 2)) #> y ~ x + protect(x * 2)
Interaction terms:
julia_formula(y ~ a:b) #> y ~ a & b
Example
julia_formula(
y ~ a + I(a * 2) + b + a:b + (a || g) + (b | g)
)
#> y ~ a + protect(a * 2) + b + (a & b) + zerocorr(a | g) + (b |
#> g)