我正在尝试将我的Shiny应用程序分解为更小的文件,以便通过git与同事进行协作变得更加容易. 这个问题帮助我弄清楚如何source()通过使用文件到我的server.r source(...,local=T).现在我正在尝试用我的UI层做同样的事情.
考虑这个玩具闪亮的应用程序:
library(shiny)
ui <- bootstrapPage(
plotOutput("test"),
numericInput("n","Number of points",value=100,min=1)
)
server <- function(input, output, session) {
output$test = renderPlot({
x = rnorm(input$n)
y = rnorm(input$n)
plot(y~x)
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)
这个应用程序可以实现您所期望的,一个100个随机数据点的过宽图表.现在,如果我想将其移动plotOutput到一个单独的文件(真正的用例是将UI的整个选项卡移动到单独的文件中).我创建了一个名为tmp.R的新文件,它具有:
column(12,plotOutput("test"),numericInput("n","Number of points",value=100,min=1))
Run Code Online (Sandbox Code Playgroud)
将它包装在column语句中的原因是因为逗号不能只是挂出来.现在我将我的UI更新为:
library(shiny)
ui <- bootstrapPage(
source("tmp.R",local=T)
)
server <- function(input, output, session) {
output$test = renderPlot({
x = rnorm(input$n)
y = rnorm(input$n)
plot(y~x)
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)
如何消除这个词出现?为什么会这样?
我正在研究玩具 Alexa 技能,并且正在遵循猜数字游戏中的示例(此处为代码)。在例子中他们
from ask_sdk_core.handler_input import HandlerInput
@sb.request_handler(can_handle_func=is_request_type("LaunchRequest"))
def launch_request_handler(handler_input):
"""Handler for Skill Launch.
Get the persistence attributes, to figure out the game state.
"""
# type: (HandlerInput) -> Response
attr = handler_input.attributes_manager.persistent_attributes
Run Code Online (Sandbox Code Playgroud)
这个attr对象允许我在整个会话中保留信息。在 Alexa 开发者控制台中,我在 'session':'attributes' 下的 JSON 中看到此数据 - 我还看到 'session':'user':'userId'
如何userId使用此函数中的 handler_input访问数据?
默认情况下,使用navbarPage()in Shiny将创建一个“静态顶部”引导页面(例如)。如果我正在为网页编写html,则可以添加一个<ul>元素,该元素带有一类的nav navbar-nav navbar-right,这些元素navbar-right会将制表符/菜单移动到导航栏的右侧。
似乎没有一种方法可以直接通过框架强制这种行为-是否有一种聪明的已知方法可以完成此任务?
使用officerR中的包时,使用PowerPoint时,您可以使用该功能添加文本ph_with_text.但是,目前尚不清楚如何添加多个文本项目符号或如何设置缩进级别.我想实现以下结构:
我尝试过两种方法都会产生非常错误的结果.我尝试了我的文本并添加\n并\n\t创建换行符和标签(就像我将如何在PowerPoint中创建结构一样).
doc = read_pptx()
doc = add_slide(layout = "Title and Content", master = "Office Theme")
doc = ph_with_text(doc,type = "body",
str = "Question 1\n\tAnswer 1\n\tAnswer 2\nQuestion 2\n\tAnswer 1\n\tAnswer 2",
index = 1)
Run Code Online (Sandbox Code Playgroud)
这会产生子弹,但不会产生深度.在每个答案之前,每个项目符号后面都有一个空白选项卡.此外,这些不是新的项目符号,如果我手动编辑文件并按下一个项目符号上的选项卡,之后的每个点也会移动.显然,没有实现正确的结构.
我也试过ph_with_text反复打电话.
doc = add_slide(layout = "Title and Content", master = "Office Theme")
doc = ph_with_text(doc,type = "body", str = "Question 1", index = 1)
doc = ph_with_text(doc,type = "body", str …Run Code Online (Sandbox Code Playgroud)