Mixing R and Python in the same Jupyter Notebook and finding Python code within an RMarkdown document
Thomas Jollans
tjol at tjol.eu
Sat Nov 3 06:55:11 EDT 2018
On 03/11/2018 00:17, Spencer Graves wrote:
> Hello, All:
>
>
> Two questions:
>
>
> 1. Is it feasible to mix R and Python code in the same
> Jupyter notebook? If yes, can you please point me to an example?
While Jupyter are always linked to *one* specific language, rpy2's
ipython %%R magic lets you intersperse calls to R from Python notebooks
(much like the %%cython magic)
https://rpy2.bitbucket.io/
example: http://lgautier.github.io/jpd-pdapr-slides/notebooks/potholes.html
>
>
> 2. How can one find Python code from within and R Markdown
> document?
>
>
> ** "https://github.com/sbgraves237/radioMonitor"
> includes "radioMonitor-init2018-10-11.Rmd" that shows it's possible to
> mix R and Python snippets in the same R Markdown (*.Rmd) document.
> However, "radioMonitor0_1.Rmd" calls 'system("py idle0_1.py")' in an R
> snippet, which does what I want (namely recording 5 seconds of whatever
> is connected to "audio in" or something similar on your computer and
> writing it to "KKFI2018-10-12t13_16-5sec.wav".
>
>
> Thanks,
> Spencer Graves
>
More information about the Python-list
mailing list