Re: [R] integrate with vector arguments

2015-02-27 Thread David Winsemius
On Feb 27, 2015, at 4:49 AM, marKo mton...@ffri.hr wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Gee. That simple. I knew that! Thanks a lot. Essentially, I needed only the diagonal elements. Easily solved by: diag(outer( X=v1,Y=v2, FUN= fV) I am sure that there are

Re: [R] integrate with vector arguments

2015-02-27 Thread marKo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Yes. That's it. Thanks, a lot, really. Marko On 02/27/2015 02:46 PM, David Winsemius wrote: On Feb 27, 2015, at 4:49 AM, marKo mton...@ffri.hr wrote: Gee. That simple. I knew that! Thanks a lot. Essentially, I needed only the diagonal

Re: [R] integrate with vector arguments

2015-02-27 Thread marKo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Gee. That simple. I knew that! Thanks a lot. Essentially, I needed only the diagonal elements. Easily solved by: diag(outer( X=v1,Y=v2, FUN= fV) I am sure that there are simpler options, but that works like a charm. Thanks a lot. Cheers, Marko

Re: [R] integrate with vector arguments

2015-02-26 Thread JS Huang
Hi, The following works. f2 function(z) { f1 - function(t) { z*t + z*t^2 } return(f1) } sapply(1:5,function(x)integrate(f2(x),0,1)$value) [1] 0.83 1.67 2.50 3.33 4.17 -- View this message in context:

Re: [R] integrate with vector arguments

2015-02-26 Thread David Winsemius
On Feb 26, 2015, at 1:49 PM, marKo mton...@ffri.hr wrote: v1-c(1:5) v2-c(1:5) f1-function (x) {v1*x+v2*x^2} The problem is that integrate(f1, 0, 1) does not work. I does not, even if a pas the arguments (v1, v2) f1-function (x, v1, v2) {v1*x+v2*x^2} or if i try to vectorize the

[R] integrate with vector arguments

2015-02-26 Thread marKo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I'm a bit stuck. I have to integrate a series of polynomial functions with vector arguments. v1-c(1:5) v2-c(1:5) f1-function (x) {v1*x+v2*x^2} The problem is that integrate(f1, 0, 1) does not work. I does not, even if a pas the arguments (v1, v2)

Re: [R] integrate with vector arguments

2015-02-26 Thread Hans W Borchers
marKo mtoncic at ffri.hr writes: I'm a bit stuck. I have to integrate a series of polynomial functions with vector arguments. v1-c(1:5) v2-c(1:5) f1-function (x) {v1*x+v2*x^2} The problem is that integrate(f1, 0, 1) does not work. The point is not that there are vector arguments, but