Bar*_*tek 4 r jupyter jupyter-notebook jupyter-irkernel
我想尝试使用R内核在jupyter中生成报告(pdf和html)。但是,我想以两种方式隐藏代码,具体取决于受众:
当我寻找这个时,我找到了python内核的答案。在R中有没有办法做到这一点(没有python代码)?
因此,我开始结合python的答案: 如何在用nbviewer可视化的ipython Notebook中的单元格中隐藏代码? 与 如何使胶乳/ HTML中Jupyter(R)? 而且有效。如果将以下代码放在单元格中,将显示一个用于隐藏代码的按钮。我想从这里开始。
library(IRdisplay)
display_html(
'<script>
code_show=true;
function code_toggle() {
if (code_show){
$(\'div.input\').hide();
} else {
$(\'div.input\').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()">
<input type="submit" value="Click here to toggle on/off the raw code.">
</form>'
)
Run Code Online (Sandbox Code Playgroud)