为什么纯R脚本的输入不同于R和Python脚本的组合?

2024-04-29 02:43:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我在R中有这样一个脚本:

from rpy import * 
r.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)

它给了我这个输出:

$stats
[1]    203.900   1834.375  11232.100 133262.800 232223.300

$n
[1] 7

$conf
[1] -67254.84  89719.04

$fence
[1]   -6963.467 5097118.725

$out
[1] 3445532344

相同的脚本,但它是R和python的混合体:

#!/usr/bin/python
from rpy import * 
r.library("robustbase") 

r("adjboxStats")(r.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)

给我这个输出,它缺少fence属性(异常值)。你知道吗

{'out': [-344553234.30000001, 3445532344.3000002], 'stats': [203.90000000000001, 219.05000000000001, 7333.3250000000007, 133262.79999999999, 232223.29999999999], 'conf': [-66986.823877395305, 81653.473877395299], 'n': 8}

当我尝试像这样添加栅栏属性时:

print r("adjboxStats")(r.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, do_fence = True)

我收到以下错误消息:

rpy.RPy_RException: Error in function (x, coef = 1.5, a = -4, b = 3, do.conf = TRUE, do.out = TRUE)  :
  unused argument(s) (do.fence = TRUE)

有人知道为什么会这样吗?你知道吗

谢谢!你知道吗


Tags: fromimport脚本trueconfstatslibraryout