Showing posts with label notebook. Show all posts
Showing posts with label notebook. Show all posts

Monday, February 27, 2017

Calling R from inside a Jupyter notebook

I use mostly python + jupyter in my research--in this case astronomical data science--workflow. One challenge I have been facing recently is dealing with time series. Some of the routines I need to use were written in R. There are versions of them for python but they seem to be inferior. The question then is: is it possible to easily interface with R functions from inside a jupyter python notebook? The answer is--amazingly--yes!

To illustrate how easy this is, I create a jupyter notebook available on Gist. This notebook demonstrates how to:

  1. generate some simple mock data with python/numpy
  2. import that data on R
  3. perform a linear fit using R's methods and load the results back to python
  4. plot the R fit with python
This may sound complicated but it really isn't.

Image

Image

Monday, September 9, 2013

Easily run fortran code from an IPython notebook cell

I just learned a potentially very useful trick for people running fortran code. By following the instructions on this link, you can copy and paste fortran code to an IPython notebook cell and then use a ipython magic command to run it on-the-fly. I haven't had time to test it yet, so if you have success with it, please let me know. Kudos to @fperez_org.

On a separate note, IPython 1.1 is out!

Update (Sep. 23rd 2013): Here is a tutorial on how to use the fortran IPython magic.