【发布时间】:2021-08-27 01:20:00
【问题描述】:
我有这个 Rmarkdown,带有 python 函数:
---
title: "An hybrid experiment"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(reticulate)
```
```{r}
selectInput("selector",label = "Selector",
choices = list("1" = 1, "2" = 2, "3" = 3),
selected = 1)
```
```{python}
def addTwo(number):
return number + 2
```
我尝试在反应式上下文中使用函数addTwo,所以我尝试了这个:
```{r}
renderText({
the_number <- py$addTwo(input$selector)
paste0("The text is: ",the_number)
})
```
但是我收到了这个错误:
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
Detailed traceback:
File "<string>", line 2, in addTwo
我一定是做错了什么,请你指导我解决这个问题吗?
【问题讨论】:
标签: r shiny r-markdown reticulate