Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
变量为R的和函数_R_Quantitative Finance - Fatal编程技术网

变量为R的和函数

变量为R的和函数,r,quantitative-finance,R,Quantitative Finance,我是R方面的新手,我正在尝试为以下几个术语创建函数。 有没有办法创建此函数的和:(1000*(1.1)^−2 + 2,000 * ( 1.1 )^−4) 其中数字1.0002000是变量,数字2,4对应于这些变量? (例如1000->2和2000->4) (这个例子只有2个术语和4个变量,我想为terms=variables/2创建总和)你的意思是这样的吗 a <- c(1000, 2000) b <- c(2, 4) sum(a * 1.1^(-b)) a(x*(1.1)^−2+

我是R方面的新手,我正在尝试为以下几个术语创建函数。 有没有办法创建此函数的和:(1000*(1.1)^−2 + 2,000 * ( 1.1 )^−4) 其中数字1.0002000是变量,数字2,4对应于这些变量? (例如1000->2和2000->4)
(这个例子只有2个术语和4个变量,我想为terms=variables/2创建总和)

你的意思是这样的吗

a <- c(1000, 2000)
b <- c(2, 4)
sum(a * 1.1^(-b))
a(x*(1.1)^−2+y*(1.1)^−4) 其中c(x,y)和数字2和4分别对应于x和y。也许我需要一个循环,我不是很确定。。。