Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
225 views
in Technique[技术] by (71.8m points)

r - Quite lost with error: Error in FUN(newX[, i], ...) : unused argument (newX[, i])

Trying to plot a sequence against a function, and am currently finding it difficult to achieve much given the error that keeps popping up. Any help on the issue will be greatly appreciated.

policy_FunE <- function(sum, time, term, age, rate)
  return(sum*AExn(AM92Ul, x = age + time, n = term - time, i = rate) -
          sum * AExn(AM92Ul, x = age, n = term, i = rate)/axn(AM92Ul, x = age, n = term, i = rate) * 
           axn(AM92Ul, x = age + time, n = term - time, i = rate))

term <- 0:40
PVs <- matrix(rep(0,41),nrow=1)
for (k in 0:40){
  PVs[,k] = apply(as.matrix(term), MARGIN = 2, FUN = policy_FunE, 
                  sum = 500000, time = k, term = 40, age = 25, rate = 0.04) 
}
plot(term, PVs[1,], ylim=c(min(PVs),max(PVs)))

> for (k in 0:40){
+   PVs[,k] = apply(as.matrix(term), MARGIN = 2, FUN = policy_FunE, 
+                   sum = 500000, time = k, term = 40, age = 25, rate = 0.04) 
+ }
Error in FUN(newX[, i], ...) : unused argument (newX[, i])
question from:https://stackoverflow.com/questions/65850883/quite-lost-with-error-error-in-funnewx-i-unused-argument-newx-i

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...