I'm trying to define a Python function that involves rpy2 steps. This is my code :
from rpy2 import robjects
df=robjects.DataFrame.from_csvfile('mydataframe.csv')
dplyr = importr('dplyr')
from rpy2.robjects.lib.dplyr import DataFrame
def boxplot(x):
plot_df = (DataFrame(df).
filter('VAR1 == x' ))
grdevices.png(file='boxplot.png')
pp = ggplot2.ggplot(plot_df ) + \
ggplot2.aes_string(x='VAR1', y='VAR2') + \
ggplot2.geom_boxplot()
pp.plot()
grdevices.dev_off()
But when running boxplot(24)
for example, I get this error : object 'x' not found.
How can I mix the two ? It seems according to the doc that Python syntax ** could be a solution, but it is not clear on how to use it.
Thanks