マークダウンで書かれた一連の数学演習を光沢のあるアプリに読み込んでレンダリングしようとしています。例として、2 つの演習を考えてみましょう。ex1.Rmd
次のようになります。
A formula: $x^2=x\times{}x$.
...そしてex2.Rmd
このように:
A different formula: $x^3=x^2\times{}x$.
次のアプリを実行すると:
exercices <- c('ex1', 'ex2')
for(e in exercices) render(
input = paste0(e, '.Rmd'),
output_format = html_document()
)
shinyApp(
ui = shinyUI(htmlOutput('exercices')),
server = shinyServer(function(input, output) {
output$exercices <- renderUI({
lapply(exercices, htmlOutput, class='exercice')
})
for(e in exercices) local({
output[[e]] <- renderUI(
withMathJax(includeHTML(paste0(e, '.html')))
)
})
})
)
...最初の式しか得られません。ただし、HTML 構造では、2 つの動的 UI 要素が正しく作成されています。しかし、最初のものだけがコンテンツを持っています。
皆さん同じ結果ですか?はいの場合、何が間違っていますか?