Question

I'm looking to run some R code on python

I already installed the R package robustbase on ubunto using apt-get install r-cran-robustbase and rpy packege as well.

from the python console I can successfully run from rpy import * and r.library("robustbase") but when I run

result = robjects.FloatVector([11232.1, 234.2, 3445532344.3, 34302.3, 203.9, 232223.3, 3434.55])
print(result.r_repr())
r(adjboxStats(c(11232.1, 234.2, 3445532344.3, 34302.3, 203.9, 232223.3, 3434.55), coef = 2.5, a = -4, b = 3, do_conf = TRUE, do_out = TRUE))

to get the outliers values

But I get this error :

adjboxStats(c(11232.1, 234.2, 3445532344.3, 34302.3, 203.9, 232223.3, 3434.55), coef = 2.5, a = -4, b = 3, do.conf = TRUE, do.out = TRUE)
SyntaxError: keyword can't be an expression

when I run this on R console it works!!!

library("robustbase")
adjboxStats(c(11232.1, 234.2, 3445532344.3, 34302.3, 203.9, 232223.3, 3434.55), coef = 2.5, a = -4, b = 3, do.conf = TRUE, do.out = TRUE)

I search here , here and here but no luck. doesn anyone knows what is that error message for and is there's a way to go arround it?

Thanks!

Was it helpful?

Solution

You can't use do.conf or do.out as arguments to a Python function (even if the function will be converted to R).

Instead, call them do_conf and do_out. You were then getting tripped up by another error, which is how you refer to r("adjboxStats"):

r("adjboxStats")(result, coef = 2.5, a = -4, b = 3, do_conf = True, do_out = True)

This will fix the syntax issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top