rstudio / shiny-examples

Other
1.96k stars 3.78k forks source link

MathJax rendering in some tabpanels, and in some not (and after refresh, mathjax is loaded again differently) #125

Closed tomasj12 closed 5 years ago

tomasj12 commented 5 years ago

Hello, i have this issue with MathJax:

First this is just example code (i think there is no need to run this code, just for ,,logic''):


fluidPage(
  title = 'MathJax Example',
  navBarMenu('Nav1',
     tabPanel('Tab1',
       withMathJax(),
       p('this is working \\(a\\), and also this \\(a_{1}\\'),
       h4('Equation'),
       ('$$\\mathrm{P}(Y = 1|X)  = \\frac{e^{\\left( b_{0} + b_1   X\\right)}}{1+e^{\\left( b_{0} + b_1 X\\right) }} $$'),
h4("Table 1"),
withMathJax(),
fluidRow(column(12, align = "center", tableOutput('table1')))),
 tabPanel('Tab2',
       withMathJax(),
       p('this is working \\(b\\)', and also this \\(b_{1}\\),
       h4('Equation'),
       ('$$\\mathrm{P}(Y = 1|X)  = \\frac{e^{\\left( b_{0} + b_1   X\\right)}}{1+e^{\\left( b_{0} + b_1 X\\right) }} $$'),
h4("Table 2"),
withMathJax(),
fluidRow(column(12, align = "center", tableOutput('table2')))),
 tabPanel('Tab3',
       withMathJax(),
       p('this is working \\(c\\), and also this \\(c_{1}\\'),
       h4('Equation'),
       ('$$\\mathrm{P}(Y = 1|X)  = \\frac{e^{\\left( b_{0} + b_1   X\\right)}}{1+e^{\\left( b_{0} + b_1 X\\right) }} $$'),
h4("Table 1"),
withMathJax(),
fluidRow(column(12, align = "center", tableOutput('table1')))))
)

shinyServer(function(input, output, session) {

#..some proces with data

output$table1<- renderTable({
  data <- load_data()

  colnames(tab) <- c("Col1", "Col2")
  withMathJax()
  rownames(tab) <- c("\\(a\\)","\\(b\\)","\\(c\\)")
  tab
},
include.rownames = T,
include.colnames = T
)

output$table2<- renderTable({
  data1 <- load_data1()

  colnames(tab) <- c("Col1", "Col2")
  withMathJax()
  rownames(tab) <- c("\\(a_{1}\\)","\\(b_{1}\\)","\\(c_{1}\\)")
  tab
},
include.rownames = T,
include.colnames = T
)

output$table3<- renderTable({
  data2 <- load_data2()

  colnames(tab) <- c("Col1", "Col2")
  withMathJax()
  rownames(tab) <- c("\\(a_{2}\\)","\\(b_{2}\\)","\\(c_{2}\\)")
  tab
},
include.rownames = T,
include.colnames = T
)

}

An my problem is, when i load shiny page, and check content of single tabpanel, equation and mathematical expression is always loaded, but those rownames some are render, and some not, for example in table 1 yes, and in table2 and table3 not. If i refresh again shiny application, and for example, i open the tabpanel Tab2 , those parameters is loaded, and in table1 too, but in table3 not, etc. Can you somebody tell me what is bad ?

cpsievert commented 5 years ago

Hi @tomasj12, https://community.rstudio.com/ is a much better place to ask a question like this. And if you can, please make your example reproducible as it helps us pinpoint your issue https://www.tidyverse.org/help/