我有一个python网状函数,它返回类型为(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")
这个values
列表应该作为shiny
的selectInput
{choices
参数应将name
作为显示给用户的值,将id
作为程序中处理的隐藏值
selectInput("_id", "Choose name", choices)
如何转换从Python API返回的values
以适应用例
我的同事设法想出了解决办法
相关问题 更多 >
编程相关推荐