如何在rpy2中通过ListVector乘以标量(How to multiply scalar by ListVector in rpy2)

编程入门 行业动态 更新时间:2024-10-26 16:32:10
如何在rpy2中通过ListVector乘以标量(How to multiply scalar by ListVector in rpy2)

我正在运行以下分析并尝试绘制我的模型的逆逻辑:

R.plot(formula, data=data, ylab = 'P(outcome = 1 | outcome)', xlab = 'SURVRATE: Probability of Survival after 5 Years', xaxp = c(0, 95, 19)) a = R.coef(mod1)[0] b = R.coef(mod1)[1] R.curve(invlogit(a + b*R.x))

invlogit是我通过STAP访问的R函数。

一切都很好,但是当我运行curve函数时,出现TypeError: unsupported operand type(s) for *: 'float' and 'ListVector'错误TypeError: unsupported operand type(s) for *: 'float' and 'ListVector' ...

我已经尝试过各种处理方式,比如使用np.multiply等,都无济于事。 我如何处理python中ListVector的标量乘法?

I'm running the following analysis and trying to plot the inverse logit of my model:

R.plot(formula, data=data, ylab = 'P(outcome = 1 | outcome)', xlab = 'SURVRATE: Probability of Survival after 5 Years', xaxp = c(0, 95, 19)) a = R.coef(mod1)[0] b = R.coef(mod1)[1] R.curve(invlogit(a + b*R.x))

invlogit is an R function that I am accessing via STAP.

Everything works great, but when I run the curve function, I get an error that TypeError: unsupported operand type(s) for *: 'float' and 'ListVector'...

I've tried various ways of handling this, like using np.multiply among others, all to no avail. How do I handle multiplication of a scalar by a ListVector within python?

最满意答案

Kludgey解决方案就是使用rmagic命令。 它似乎是将我所有的R代码转换为rpy2等价物的阻力最小的路径。

Kludgey solution is to just use the rmagic commands. It appears to be the path of least resistance to convert all my R code to the rpy2 equivalent.

更多推荐

本文发布于:2023-08-02 19:57:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1380630.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:标量   如何在   ListVector   multiply   scalar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!