我正在尝试在Jupyter笔记本中遵循here中的教程。为此,我正在运行提供的所有代码,不同之处在于,我尝试按照rpy2教程中的指示运行robjects。但是,如何使图块起作用呢?:
ro.r('''
[remaining code]
gp = ggplot2.ggplot(mtcars)
pp = gp + ggplot2.aes_string(x='wt', y='mpg') + ggplot2.geom_point()
pp.plot()
''')
这不返回任何内容。如果我这样做:
p=ro.r('''
ggplot(mtcars)
''')
p
它返回以下错误:
TypeError: 'NULLType' object is not iterable
R object with classes: ('gg', 'ggplot') mapped to:
[ListSexpV..., ListSexpV..., SexpEnvir..., ListSexpV..., ..., SexpEnvir..., SexpEnvir..., SexpEnvir..., ListSexpV...]
data: <class 'rpy2.rinterface.ListSexpVector'>
<rpy2.rinterface.ListSexpVector object at 0x2b6e6f8e7ec8> [RTYPES.VECSXP]
layers: <class 'rpy2.rinterface.ListSexpVector'>
<rpy2.rinterface.ListSexpVector object at 0x2b6e6f8e7a48> [RTYPES.VECSXP]
scales: <class 'rpy2.rinterface.SexpEnvironment'>
<rpy2.rinterface.SexpEnvironment object at 0x2b6e6f8e7e08> [RTYPES.ENVSXP]
mapping: <class 'rpy2.rinterface.ListSexpVector'>
<rpy2.rinterface.ListSexpVector object at 0x2b6e6f8e7f48> [RTYPES.VECSXP]
theme: <class 'rpy2.rinterface.ListSexpVector'>
<rpy2.rinterface.ListSexpVector object at 0x2b6e6f8e7ec8> [RTYPES.VECSXP]
coordinates: <class 'rpy2.rinterface.SexpEnvironment'>
<rpy2.rinterface.SexpEnvironment object at 0x2b6e6f8e7e88> [RTYPES.ENVSXP]
facet: <class 'rpy2.rinterface.SexpEnvironment'>
<rpy2.rinterface.SexpEnvironment object at 0x2b6e6f8e7f48> [RTYPES.ENVSXP]
plot_env: <class 'rpy2.rinterface.SexpEnvironment'>
<rpy2.rinterface.SexpEnvironment object at 0x2b6e6f8e7e08> [RTYPES.ENVSXP]
labels: <class 'rpy2.rinterface.ListSexpVector'>
<rpy2.rinterface.ListSexpVector object at 0x2b6e6f8e7ec8> [RTYPES.VECSXP]