Passing arguments to a python function in reticulate in R

Viewed 1230

I have problem passing arguments to an imported function from a python module(via reticulate)

This code works in python but following code in R does not

from frs import frs
 frs(gender='F', time=10, age=35, bmi=24.3, sbp=122, ht_treat=False, smk=True, dia=False)

 X = ['m', 10, 30, 22.5, 125.0, True, True, True]
frs(*X) 

    #My unsuccessful attempt in R



    library(reticulate)

    frs= import('frs')

    ##Attempt1

    frs$frs(c('m', 10, 30, 22.5, 125.0, "True", "True", "True"))

    #attempt2

    gender= 'm'

    time=10

    age=35
    bmi =23.5

    sbp = 120
    ht_treat = TRUE
    smk = TRUE

    dia =TRUE

    frs$frs(c(gender,time,age,bmi,sbp,ht_treat,smk,dia)) 
1 Answers

Call Python within R:

library(reticulate)
reticulate::repl_python()
import frs
frs(gender='F', time=10, age=35, bmi=24.3, sbp=122, ht_treat=False, smk=True, dia=False)
Related