R/python-functions.R

spacyr_pyassign <- function(pyvarname, values) {
    main <- reticulate::import_main()
    eval(parse(text = sprintf("main$%s <- reticulate::r_to_py(values)", pyvarname)))
}

spacyr_pyget <- function(pyvarname) {
    main <- reticulate::import_main()
    return(eval(parse(text = sprintf("main$%s", pyvarname))))
}

spacyr_pyexec <- function(pystring = NULL, pyfile = NULL) {
    if (!is.null(pystring)) {
        reticulate::py_run_string(pystring)
    }
    if (!is.null(pyfile)) {
        reticulate::py_run_file(pyfile)
    }
}

Try the spacyr package in your browser

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

spacyr documentation built on July 4, 2019, 5:05 p.m.