R shinny:交互式渲染乳胶
在R Shining中使用乳胶,我发现这个技巧很有用。对不起,我的知识和声誉太短,无法在此发表评论。 但至少对我来说,它不能以交互方式工作。我找到了一个解决办法,以获得良好的外观。但我得到了原始的LaTeX代码,就好像我直接运行Stefanies示例一样。 这是我的密码R shinny:交互式渲染乳胶,r,latex,shiny,R,Latex,Shiny,在R Shining中使用乳胶,我发现这个技巧很有用。对不起,我的知识和声誉太短,无法在此发表评论。 但至少对我来说,它不能以交互方式工作。我找到了一个解决办法,以获得良好的外观。但我得到了原始的LaTeX代码,就好像我直接运行Stefanies示例一样。 这是我的密码 library(shiny) library(xtable) if (!exists("dummy.output")) dummy.output <- NULL ui <- shinyUI(pageWithSi
library(shiny)
library(xtable)
if (!exists("dummy.output")) dummy.output <- NULL
ui <-
shinyUI(pageWithSidebar(
# Application title
headerPanel(
HTML("App with $\\int \\alpha^2 $ und $$\\beta/3 $$")),
# Sidebar with a slider input for number of observations
sidebarPanel(
tags$head( tags$script(src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full", type = 'text/javascript'),
tags$script(src = 'https://c328740.ssl.cf1.rackcdn.com/mathjax/2.0-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML', type = 'text/javascript'),
tags$script( "MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});", type='text/x-mathjax-config')
),
sliderInput(
inputId = "n",label = HTML("Dimension $ \\beta $"),
value = 5,min = 3,max = 7,step = 1)
),
# Show a plot of the generated distribution
mainPanel(
HTML("$\\alpha$ und $\\Omega$"),
uiOutput("test.html"),
uiOutput("matrix.raw"),
#uiOutput("matrix.nicer"),#ging nicht
p(br()),
uiOutput("matrix.nicer"),
p(br()),
p("doesn' work, so brutal work with dummy.output made matrix ",
"nice but then without intereactivity"),
HTML(dummy.output),
HTML("End.$\\clubsuit$")
)
))
server <- function(input,output){
output$test.html <- renderPlot({plot(rnorm(50))})
mk.matrix <- reactive({
n <- input$n
x <- (5:(4+n^2))/4
mm <- matrix(x^2,nrow = n)
rownames(mm) <- letters[1:n]
return(mm)
})
output$matrix.raw <- renderTable({mk.matrix()})
output$matrix.nicer <- renderUI({
mm <- mk.matrix()
mm <- print(
xtable(mm, align=rep("c", ncol(mm)+1)),
floating=FALSE, tabular.environment="array",
comment=FALSE, print.results=FALSE)
xx <- paste0("$$", mm, "$$")
dummy.output <<- xx
return(xx)
})
}
runApp(list(ui=ui,server=server))
最酷的作品是标题和文本中的所有符号。所以我相信我的互动设置有问题 一个简单的答案是实现定制的OutputBinding。在server.R中,您可以编写自己的渲染函数(相当于一个非常薄的包装器),并将latex发送到客户端。在客户端,使用MathJax进行渲染。有关更多详细信息:您好,我认为您应该使用。或者您可以只设置type=html。