在Shiny输出中显示变量

时间:2019-08-07 12:46:38

标签: r shiny

我有一个闪亮的应用程序,我想在其中显示一些用户数据到另一个页面。这是我的UI代码

     static void Main(string[] args)
    {
        using (var writer = File.OpenWrite("c:/temp/test.xps"))
        {
            using (var s = getXpsStream())
            {
                s.Seek(0, SeekOrigin.Begin);
                s.CopyTo(writer);
            }
        }
    }
    static Stream getXpsStream()
    {
        var stream = new MemoryStream();
        var package = Package.Open(stream, FileMode.Create);
        var xpsDoc = new XpsDocument(package, CompressionOption.Normal);
        var xpsWriter = xpsDoc.AddFixedDocumentSequence();
        string tempPath = "c:/temp/Document";
        for (int i = 1; i <= 3; i++)
        {
            var docWriter = xpsWriter.AddFixedDocument();
            var pageWriter = docWriter.AddFixedPage();
            var image = pageWriter.AddImage(XpsImageType.JpegImageType);

            using (Stream imageStream = image.GetStream())
            {
                string filename = tempPath + i;
                using (var istream = File.OpenRead(filename + ".png"))
                {
                    istream.CopyTo(imageStream);
                }
            }
        }
        xpsDoc.Close();
        return stream;
    }

然后在服务器上,我获取用户输入,并将其保存在变量中,然后再次显示出来。

home_page <- page("Home page", uiOutput("current_page"), form = 
fluidPage(
 textInput(inputId = "app_name", label="Please enter the name of your application", value="app_x")
))

但是当我尝试以另一种方式显示变量时,启动应用程序时出现此错误。

output$application_name <- renderText(application_name)

我尝试在我的UI中显示这样的变量

Error in page("Read Data", uiOutput("current_page"), content = "This page is used to preproccess data for the given files",  : 
  unused argument (mainPanel(textOutput("application_name")))

1 个答案:

答案 0 :(得分:0)

我认为您的renderText遇到了问题,即您没有正确获取用户输入。这是有关此操作的简单示例:

library(shiny)
ui <- fluidPage(

        mainPanel(
            textInput(inputId = "app_name", label="Please enter the name of your application", value="app_x"),
            textOutput("application_name")
    )
)

server <- function(input, output) {

    output$application_name <- renderText(paste(input$app_name))
}

# Run the application 
shinyApp(ui = ui, server = server)