如何在R中编写函数

问题描述

提供了功能

enter image description here

我不确定如何用R编写它,我将其写为:

enter image description here

但是我遇到了这个错误

ti

解决方法

也许您正在寻找这个:

#Function
f <-function(x) {4*x*exp(-2*x)}
#Integral
integrate(f,lower = 0,upper = Inf)