R/julia/julia.R

Defines functions wBisquare_julia julia_init julia_setup

env <- list2env(list(.julia = FALSE))

#' julia_init
#' 
#' @keywords internal
#' @import JuliaCall
#' @export
julia_setup <- function() {
    JuliaCall::julia_setup()
    # print(infile)
    JuliaCall::julia_library("phenofit")
    # JuliaCall::julia_library("nlminb")
    # infile <- system.file("julia/wBisquare.jl", package = "phenofit")
    # JuliaCall::julia_source(infile)
}

#' @importFrom JuliaCall julia_setup julia_source julia_call
julia_init <- function() {
    if (!env$.julia) {
        env$.julia = TRUE
        julia_setup()
    }
}


wBisquare_julia <- function(y, yfit, w, ..., wmin = 0.2, 
    trs_high = 0.6,
    trs_low  = trs_high,
    trs_bg = 0.2, 
    .toUpper = TRUE)
{
    julia_init()
    if (missing(w)) w  <- rep(1, length(y))
    wnew = JuliaCall::julia_call("phenofit.wBisquare", y, yfit, w,
        wmin = wmin,
        trs_high = trs_high,
        trs_low  = trs_low,
        trs_bg = trs_bg)
    return(wnew)
}

Try the phenofit package in your browser

Any scripts or data that you put into this service are public.

phenofit documentation built on Feb. 16, 2023, 6:21 p.m.