It might be a very simple question (although it seems long).
I installed Jupyter today from pip and pip3, so can set kernel as python2 or 3. Then started with an example taken from datacamp, it is:
# Hide warnings if there are any
import warnings
warnings.filterwarnings('ignore')
# Load in the r magic
%load_ext rpy2.ipython
# We need ggplot2
%R require(ggplot2)
# Load in the pandas library
import pandas as pd
# Make a pandas DataFrame
df = pd.DataFrame({'Alphabet': ['a', 'b', 'c', 'd','e', 'f', 'g', 'h','i'],
'A': [4, 3, 5, 2, 1, 7, 7, 5, 9],
'B': [0, 4, 3, 6, 7, 10, 11, 9, 13],
'C': [1, 2, 3, 1, 2, 3, 1, 2, 3]})
# Take the name of input variable df and assign it to an R variable of the same name
%%R -i df
# Plot the DataFrame df
ggplot(data=df) + geom_point(aes(x=A, y=B, color=C))
when press Ctrl+enter it returns:
File "<ipython-input-4-d85184fd21a2>", line 21
%%R -i df
^
SyntaxError: invalid syntax
I have looked in the web but not sure what is the source of error. It might be something in my debian-stretch packages.
Example taken from https://www.datacamp.com/community/tutorials/tutorial-jupyter-notebook
Would you help me?
EDIT Code as proposed in one answer (by Vin) gives this output:
R object with classes: ('gg', 'ggplot') mapped to:
<ListVector - Python:0x7fe4b3a62e48 / R:0x5587100234b8>
[DataF..., ListV..., Envir..., ..., Envir..., Envir..., ListV...]
R object with classes: ('gg', 'ggplot') mapped to:
<ListVector - Python:0x7fe4b3a62e48 / R:0x5587100234b8>
[DataF..., ListV..., Envir..., ..., Envir..., Envir..., ListV...]
R object with classes: ('gg', 'ggplot') mapped to:
<ListVector - Python:0x7fe4b3a62e48 / R:0x5587100234b8>
[DataF..., ListV..., Envir..., ..., Envir..., Envir..., ListV...]
scales: <class 'rpy2.robjects.environments.Environment'>
R object with classes: ('ScalesList', 'ggproto') mapped to:
<Environment - Python:0x7fe4b3a5fcc8 / R:0x55870fb79730>
...
data: <class 'rpy2.robjects.environments.Environment'>
R object with classes: ('FacetNull', 'Facet', 'ggproto') mapped to:
<Environment - Python:0x7fe4b3a7e588 / R:0x55870fb05b40>
layers: <class 'rpy2.robjects.environments.Environment'>
R object with classes: ('environment',) mapped to:
<Environment - Python:0x7fe4b3a5fcc8 / R:0x55870d7f2c48>
R object with classes: ('gg', 'ggplot') mapped to:
<ListVector - Python:0x7fe4b3a62e48 / R:0x5587100234b8>
[DataF..., ListV..., Envir..., ..., Envir..., Envir..., ListV...]
But I suppose there should be some graph.