Created
October 10, 2015 11:43
-
-
Save kohske/aaf79efdd0d3a3d74101 to your computer and use it in GitHub Desktop.
RMarkdown de PythonInR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| title: "RMarkdownでPythonInR" | |
| author: '@kohske' | |
| date: "2015年10月10日" | |
| output: html_document | |
| --- | |
| 参考 https://speakerdeck.com/yamano357/tokyor51-lt | |
| フック | |
| ```{r include=FALSE} | |
| library(knitr) | |
| c2s = function(before, options, envir) { | |
| if (before) { | |
| } else { | |
| print(options) | |
| assign(options$label, paste0(options$code, collapse="\n"), envir) | |
| } | |
| } | |
| knit_hooks$set(py = c2s) | |
| ``` | |
| ```{r} | |
| library(PythonInR) | |
| ``` | |
| パイソンチャンク | |
| ```{r py1, eval=FALSE, py=TRUE, include=FALSE} | |
| a=range(0, 3) | |
| b=range(0, 5) | |
| ``` | |
| 使ってみる | |
| ```{r} | |
| pyExec(py1) | |
| pyGet("a") | |
| pyGet("b") | |
| ``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment