Html output to display the the description of each function

萝らか妹 提交于 2021-02-17 04:56:12

问题


I am trying to build a r shiny app where the user will get to know about each function in just a click. For this I have coded below in R . But print(??input$A) is not working. Could anyone help please

library(shinydashboard)
library(readxl)
out <- data.frame(baseFns = ls('package:base'))
ui <- dashboardPage(
  dashboardHeader(title = "Loading data"),
  dashboardSidebar(sidebarMenu(
    menuItem("Analysis", tabName = "Analysis", icon = icon("chart-bar"))
  )),
  dashboardBody(
    tabItems(tabItem(tabName = "Analysis",
                     fluidRow(box(selectInput("A","A",choices = c(levels(factor(out$baseFns))),width = "150px"),width = 2),
                              fluidRow(box(htmlOutput("Text"),width = 9)))
             )
    ))
)

server <- function(input,output){
  output$Text <- renderText({
    print(??input$A)
  })
}
shinyApp(ui, server)

回答1:


Here is a way:

library(shiny)
library(shinydashboard)
library(gbRd) # for Rd_fun
library(tools) # for Rd2HTML

out <- data.frame(baseFns = ls('package:base'))

ui <- dashboardPage(
  dashboardHeader(title = "Loading data"),
  dashboardSidebar(sidebarMenu(
    menuItem("Analysis", tabName = "Analysis", icon = icon("chart-bar"))
  )),
  dashboardBody(
    tabItems(
      tabItem(
        tabName = "Analysis",
        fluidRow(
          box(selectInput("A", "Topic", choices = levels(factor(out$baseFns)), 
                          width = "150px"), 
              width = 2),
          fluidRow(box(htmlOutput("helpfun"), width = 9))
        )
      )
    ))
)

server <- function(input, output, session){

  output$helpfun <- renderUI({
    Rd <- Rd_fun(help(input$A)) 
    outfile <- tempfile(fileext = ".html")
    Rd2HTML(Rd, outfile, package = "",
            stages = c("install", "render"))
    includeHTML(outfile)
  })

}

shinyApp(ui, server)


来源:https://stackoverflow.com/questions/59224534/html-output-to-display-the-the-description-of-each-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!