From now I will be posting about data science, python, R, statistics etc on a new blog: Astronomical Data Science. This blog will not be updated anymore.
Tips and tricks on using Python and associated tools for astronomical and scientific purposes. Written by an astronomer who uses Python on a daily basis to do science.
Sunday, March 5, 2017
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:
To illustrate how easy this is, I create a jupyter notebook available on Gist. This notebook demonstrates how to:
- generate some simple mock data with python/numpy
- import that data on R
- perform a linear fit using R's methods and load the results back to python
- plot the R fit with python
This may sound complicated but it really isn't.
Subscribe to:
Posts (Atom)