When did the problem arise?
I was trying to use polr() method of R
(via rpy2
) for ordinal regression analysis using the following statement. In that statement, "Number of Steps" is my dependent variable. When I set (in the column header and also in the statement) underscore replacing the spaces (i.e. Number_of_Steps), everything works fine.
model = mass.polr('as.factor(Number of Steps) ~ Var2',
data=df_data, method='logistic',
Hess = True)
# Here, mass = importr('MASS')
However, with spaces (i.e. Number of Steps), I get the following error.
RRuntimeError: Error in parse(text = x, keep.source = FALSE) :
:1:17: unexpected symbol 1: as.factor(Number of
How did I try to solve the problem?
I have searched on google and also checked different questions in SO (e.g. this one) related to this problem. However, still, I do not find the solution of this problem.
Then, my question
How can I use space separated variable name (i.e. column header) in as.factor(variable name)
during use of mass.polr()
?
Thanks for reading!