First time using the RPy2 implementation in Python. Attempting to do an one-way ANOVA with two factors. It works in R on another machine, but Python does not like the syntax. Any thoughts are appreciated!
from rpy2.robjects import aov
huanova = aov(formula = df1['human_den'] ~ df1['region']+df1['years'])
Error message points at the tilda.
huanova = aov(formula=df1['human_den'] ~ df1['region']+df1['years'])
^
SyntaxError: invalid syntax
Tilde ~
is Unary in python, but you are using it as Binary. You may want:
huanova = aov(formula = df1['human_den'] + ~ df1['region']+df1['years'])
Notice that I've added a PLUS before Tilde.