我是Shiny的新手,并试图为我构建的功能构建更易于访问的输入和输出。我把这个交给那些不运行R的人,所以试图在后台创建一些运行我的函数的东西,然后吐出答案。闪亮 - 将文本输入转换为辅助功能
我遇到了一些麻烦,不幸的是我处理了一堆错误。然而,这里是我更尖锐的问题:
我想要运行的实际功能需要一个名称(引用为“Last,First”)和一个数字。
PredH("Last,First",650)
所以我想一个闪亮的应用程序,它需要一个名称输入,输入的号码是然后运行该程序,然后吐出背出一个数据表,我的答案。所以有几个问题。
如何获得它在正确的形式输入到我的公式在服务器端脚本,我需要返回它的功能,因此它可以访问使用函数$表类型访问? (现在我只是在控制台中使用cat()函数打印函数,但知道可能不适用于此类应用程序。
我想返回可在PredH14 $表中获得的数据帧。如何着手建立闪亮
这是到目前为止我的代码:?
UI:
library(shiny)
shinyUI(pageWithSidebar(
# Application title
headerPanel("Miles Per Gallon"),
# Sidebar with controls to select the variable to plot against mpg
# and to specify whether outliers should be included
sidebarPanel(
textInput("playername", "Player Name (Last,First):", "Patch,Trevor"),
radioButtons("type", "Type:",
list("Pitcher" = "P",
"Hitter" = "H"
)),
numericInput("PAIP", "PA/IP:", 550),
submitButton("Run Comparables")
),
mainPanel(
textOutput("name")
)
服务器:
library(shiny)
shinyServer(function(input, output) {
sliderValues <- reactive({
data.frame(
Name = c("name", "PA"),
Value = c(as.character(playername),
PAIP),
stringsAsFactors=FALSE)
})
name=input[1,2]
PAIP=input[2,2]
testing <- function(name,PAIP){
a=paste(name,PAIP)
return(a) }
output$name=renderText(testing$a)
})
感谢您的回答,它一直非常有帮助。尽管问题很快。我试图将这些输入传递到另一个将存在于服务器端的函数。假设我的功能是这样的: – BaseballR
' name = input [1,2] PAIP = input [2,2] 测试< - function(name,PAIP){0} = paste(name,PAIP) 回报(一) }' ,然后要输出回到UI等等,然后做一些事情,如: '输出$名称= renderText(测试$一)' 是,你将如何得到的东西你功能? 谢谢!对不起,这个令人困惑的问题! – BaseballR
我做这种类型的事情,总是回来的类型闭合对象不子集,我无法找到任何具体到闪亮的问题的答案。 – BaseballR