[Python] rpy2 conversion-> passing a python dict to a ... argument in R

Discussão em 'Python' iniciado por Stack, Fevereiro 14, 2025.

  1. Stack

    Stack Membro Participativo

    I have a python dictionary with values defined as follows:

    dc = {
    '1': 100,
    '2': 150,
    '3': 200
    }


    And a r function defined as follows:

    Printer <- function(...) {
    for (i in list(...)) {
    print (i)
    }
    }


    So the output would be

    100
    150
    200


    The error I get when trying to pass the argument through rpy2 is


    RuntimeError: Unknown data type <class 'dict'> to pass to R algorithm.
    ​

    Question: How do I convert the elements of the python dictionary to an r list during passing from python to R?

    Continue reading...

Compartilhe esta Página