Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
xaringanパッケージの内容をちょっとだけ
Search
Kazuhiro Maeda
October 11, 2019
Technology
1.1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
xaringanパッケージの内容をちょっとだけ
Yakitori.R #02 (fukuoka.R #16)
Kazuhiro Maeda
October 11, 2019
More Decks by Kazuhiro Maeda
See All by Kazuhiro Maeda
Will Positron accelerate us? (update)
kazutan
1
210
積もってく会議メモをどうにかしたかった
kazutan
0
300
分析システムにR Markdownを組み込む
kazutan
0
580
Rに管理されてみる
kazutan
0
510
私とR、そしてキャリア
kazutan
2
4k
tubeplayR v1.0への道
kazutan
2
260
R, Git, Droneを使ってconfluenceへのKPI予測レポートを自動化した話
kazutan
2
700
週次KPIレポートをconfluenceへUpするためにやったこと
kazutan
1
1.6k
最近のRパッケージ開発事情
kazutan
0
410
Other Decks in Technology
See All in Technology
1人アドミンな私はAWSアカウント申請をSlackで完結したい!
ysuzuki
0
110
Meet AgentCore Identity Consent Portal
hironobuiga
2
150
【データ横丁主催】AI Agentがコンテキストを使って仕事をした後、何が残るのか― 組織の経験を次の判断に引き継ぐ「Agent Memory」
shisyu_gaku
2
310
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
16
120k
AI駆動開発、viviONの1年 ── うまくいったこと・いかなかったこと
vivion
0
110
カンファレンスに参加した後の浮遊感とセルフケア
pauli
0
270
1万名の社員が使う認証基盤で どう信頼性を担保するか?
kairim0
0
130
[2026-09-30]ロックンロールは鳴り止まないっ - 信頼性かまってちゃん - 「データ駆動を投げ捨ててまで。」追いかける信頼性改善に向けた取り組みの話
tosite
0
150
10年欲しかった音楽管理アプリを、AIと一緒に作りはじめた
judau
1
200
OpenClawでAzure DevOpsのWiki更新を自動化する - クラウドAIだけでは届かない場所へ
yutakaosada
0
140
Execution in the Kingdom of Agents: Reflections on Abstraction and Complexity
bcantrill
0
620
2026-10-01_MagicPod_QAハーネスエンジニアリングとQA組織の未来像
ynisqa1988
0
180
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Site-Speed That Sticks
csswizardry
13
1.5k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
500
Ethics towards AI in product and experience design
skipperchong
2
400
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
530
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
570
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Code Review Best Practice
trishagee
74
20k
WCS-LA-2024
lcolladotor
0
840
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
290
Transcript
xaringan パッケージの内容をちょっとだけ fukuoka.R / Yakitori.R kazutan 2019-10-11
今⽇のお話 xaringanパッケージとは 実はエグい実装その1 実はエグい実装その2 2 / 17
xaringan パッケージとは R NinjaことYihui作のパッケージ 基本的な情報 R Markdownでスライドを作成できる remark.jsというライブラリを活⽤ 気付いたら世界各地で流⾏った このスライドもそうです
特徴 renderが軽量 chunkの評価は別 リアルタイムで編集をPreviewできる 他のRmdスライドテンプレートとはちょいちょい書き⽅が違う 例えばスライド区切りが だったり 3 / 17
xaringan 、内部的にはかなりエグい remark.jsを利⽤している remark.jsはmarkdown記法の⽂字列を読み込んでスライド化 実はこれが問題となる(後述) R Ninjaは「隠れ蓑の術」でクリアした リアルタイム編集(markdownレンダリング) 本来R MarkdownはrenderしないとViewerに出せない
R Ninjaはこれを「無限⽉読」(個⼈的には千⾥眼?)でクリアした 今⽇はこのあたりを簡単に紹介 4 / 17
おさらい: R Markdown の処理 詳しくは以下の記事を参照: R Markdownの内部とテンプレート開発 https://kazutan.github.io/TokyoR61/intoTheRmarkdown_d.html R Markdown
の流れ <Pandoc 系> <knit 系> .md pre_processor html, docs, pdf... output_format post_processor Pandoc .Rmd フォーマット テンプレ pre_knit .md output_format post_knit knit 5 / 17
忍法「隠れ蓑の術」 課題1 remark.jsはmarkdown記法を対象とするけど、Pandocを通すと強制的にhtmlにされてしま う。どうしたらいいか? R Ninjaの回答 スライドに表⽰させるドキュメント部分をバイパスさせればいい は? 6 /
17
忍法「隠れ蓑の術」 コード部分(1) バイパスさせるために、⼀時ファイルを準備 https://github.com/yihui/xaringan/blob/master/R/render.R#L84 コメントでも書いてますね tmp_md = tempfile('xaringan', fileext =
'.md') # store md content here (bypass Pandoc 7 / 17
忍法「隠れ蓑の術」 コード部分(2) 以下の処理をpre_processorとして準備 Rmdファイルからyamlとbodyを分離させる body部分をさっきの添付ファイルに書き込む https://github.com/yihui/xaringan/blob/master/R/render.R#L172-L185 pre_processor = function( metadata,
input_file, runtime, knit_meta, files_dir, output_dir ) { res = split_yaml_body(input_file) write_utf8(res$yaml, input_file) res$body = protect_math(res$body) content = htmlEscape(yolofy(res$body, yolo)) Encoding(content) = 'UTF-8' write_utf8(content, tmp_md) c( if (seal) c(' variable', 'title slide=true'), if (!identical(body, res$body)) c(' variable', 'math=true') ) }, 8 / 17
忍法「隠れ蓑の術」 コード部分(3) pandocによる変換処理の後に、Pandocの挿⼊機能を使って差し込む https://github.com/yihui/xaringan/blob/master/R/render.R#L119-L138 html_document2 = function( , includes =
list(), mathjax = 'default', pandoc_args = NULL ) { if (length(includes) 0) includes = list() includes$before_body = c(includes$before_body, tmp_md) includes$after_body = c(tmp_js, includes$after_body) 実際には細かい調整とかしてるけど、⼤まかにはこんな感じです 9 / 17
忍法「無限⽉読」 課題2 どうやってリアルタイムレンダリングしてるの? R Ninjaの回答 こんな感じで: 1. 簡易的なHTTPサーバーを起動させる servr パッケージで実現
2. 必要なライブラリを送る remark.jsなど 3. RmdファイルをHTTPサーバーへ送り、Viewerに表⽰させる Viewerについてはこちら tubeplayRパッケージはなぜRStudio上でYouTubeを再⽣できるのか 4. Rmdファイルをモニタリングし、変更を察知したらそれをサーバーへ送る rstudioapiを駆使している remark.jsがmdを読み込むというのがポイント 5. 変更を察知したら、Viewerを再読み込みさせる 10 / 17
まとめ R Ninjaまじすごい 11 / 17
おまけ 12 / 17
13 / 17
14 / 17
15 / 17
みんなNinja になろう 16 / 17
Enjoy! 17 / 17