logopt: a journey in R, Python, finance and open source 2017-05-02 21:35:00
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
A R named list is not a python dictionary¶
In the previous post, mpiktas posted a comment that included this question “Isn’t Python dictionary a named list in R?”. The short answer is no, but the reason why is worth some more explanation.
At first sight, a named list does look a little bit as a python dictionary, it allows to retrieve values inside a list using names (i.e. strings) instead of by numerical index. The code below is also a good example on how it is possible to mix R and python code inside a Jupyter notebook
%load_ext rpy2.ipython
%R RL <- list('one'=1, 'two'=2, 'three'=3) ; RL[['one']]
array([ 1.])