简体   繁体   中英

Passing arguments to a python function in reticulate in R

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)) 

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM