gpt4 book ai didi

r - 如何在 R 中使用 nthroot 函数

转载 作者:行者123 更新时间:2023-12-05 00:58:13 25 4
gpt4 key购买 nike

我正在尝试使用 pracma 包中的 nthroot 函数。但是,每当我运行它时,都会出现错误:

Error in nthroot(x, 5) : could not find function "nthroot"

我尝试安装 pracma 包,但这也无济于事。谁能给我任何关于为什么这不起作用的想法?

最佳答案

nthroot 处理负数,例如返回 nthroot(-2,3) == -1.259921,而不是 NA

自己定义:

nthroot = function(x,n) {
(abs(x)^(1/n))*sign(x)
}

关于r - 如何在 R 中使用 nthroot 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58447310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com