Reputation: 71
Good morning. Please how to render mathematic equations like null and alternative hypothesis in formattable? The code is just a minimal example
sliderInput("significance",strong("Significance level :"),min = 0,max = 0.2,value = 0.10),
withMathJax(), formattableOutput("our_result")
output$our_result <- renderFormattable({
dt3_new <- data.frame(close = c(0.004, 4.05),
junior= c(2.001, 0.00007891),
child = c(4.5, 0.007891),
Lala= c(0.001, 0.00007891))
my_result1 <- as.data.frame(matrix(NA, ncol = 4, nrow = 2))
for ( i in 1 : 4){
if (is.numeric(dt3_new[[1, i]])){
if (as.numeric(dt3_new[[1, i]]) > as.numeric(input$significance) ) {
my_result1[[1, i]] <- "$$H_0$$ accepted, we can assume normality"
} else {my_result1[[1, i]] <- "$$H_0$$ denied, the data is not normaly distributed"}
} else {
my_result1[[1, i]] <- "Test can not be apply because the sample is very small"
}
if (is.numeric(dt3_new[[2, i]])){
if (as.numeric(dt3_new[[2, i]]) > as.numeric(input$significance) ) {
my_result1[[2, i]] <- paste0("\\( H_0\\) accepted; the sample distribution is not stationary")
} else {my_result1[[2, i]] <- paste0("\\( H_0\\) denied; the sample distribution is stationary")}
} else {
my_result1[[2, i]] <- "Test can not be apply because the sample is very small"
}
}
})
Upvotes: 1
Views: 313
Reputation: 84599
Use some dollars for the MathJax code:
library(shiny)
library(formattable)
ui <- fluidPage(
withMathJax(),
formattableOutput("ftable")
)
server <- function(input, output){
output$ftable <- renderFormattable({
formattable(data.frame(x = "$$H_0$$"))
})
}
shinyApp(ui, server)
Upvotes: 2