开发者

Returning function output on array of values in R

I'm a beginner R programmer struggling with a multivariate array problem.

I'm attem开发者_StackOverflowpting to input an array of 4 parameter values, say a=1:10, b=1:10, p=1:10, q=1:10, into a function y=f(x|a, b, p, q) that calculates values of y based on my dataset, x, and every possible combination of the given 4 parameters [(a=1,b=1,p=1,q=1),(a=2,b=1,p=1,q=1),...,(a=10,b=1,p=1,q=1),...,(a=10,b=10,p=10,q=10)] = 10^4 = 10,000 possible combinations and therefore 10,000 y values.

Ideally I'd like the output to be in an array format which I can then graph in R, allowing each parameter to be plotted as a separate axis.

If anyone could point me in the right direction it would be much appreciated!

Thanks,

Robert


I agree with JD Long that the request is too vague to allow a final answer, but there is an answer to the first part:

all.comb.dfrm  <- expand.grid(a=1:10, b=1:10, p=1:10, q=1:10)
all.comb.dfrm$Y <- with(all.comb.dfrm, f(a,b,p,q) )
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜