I have python reticulate function which returns list of two length tuples of type (id, name).
# In the python API
returned_list = [
(1, "Jon Doe"),
(2, "Jane Doe"),
]
library(shiny)
library(reticulate)
# source and other staff
API <- pythonAPI()
values <- API.call() # Returns R list of 2 length lists
values
# [,1] [,2]
# [1,] List,2 List,2
for(index in 1:length(values)){
message(values[index])
# list(1, "Jon Doe")
# list(2, "Jane Doe")
This values list is supposed to go as choices for shiny's selectInput choices parameter. This choices parameter should have name as the value shown to the user and id as hidden value processed in the program.
selectInput("_id", "Choose name", choices)
How to transform values returned from Python API to fit use-case?