How to assign result of integrate in R to a numeric variable?

≯℡__Kan透↙ 提交于 2019-12-01 19:50:22

The result of integrate is a list:

> temp <- integrate(f,0,Inf)
> temp
120 with absolute error < 7.3e-05
> str(temp)
List of 5
 $ value       : num 120
 $ abs.error   : num 7.34e-05
 $ subdivisions: int 5
 $ message     : chr "OK"
 $ call        : language integrate(f = f, lower = 0, upper = Inf)
 - attr(*, "class")= chr "integrate"

You can access elements by name:

> temp$value
[1] 120

... or by index:

> temp[[2]]
[1] 7.335833e-05
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!